test(e2e): menu/basic

This commit is contained in:
Daniel Imhoff
2017-03-03 14:47:36 -06:00
parent 552a88c73b
commit a43386a405
18 changed files with 225 additions and 146 deletions

View File

@ -1,145 +0,0 @@
import { Component, ViewChild, NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AlertController, IonicApp, IonicModule, MenuController, ModalController, NavController, Nav, ViewController } from '../../../..';
@Component({
templateUrl: 'page1.html'
})
export class Page1 {
constructor(
public navCtrl: NavController,
public alertCtrl: AlertController,
public modalCtrl: ModalController) { }
myMenu: string = 'right';
presentAlert() {
let alert = this.alertCtrl.create({
title: 'New Friend!',
message: 'Your friend, Obi wan Kenobi, just accepted your friend request!',
cssClass: 'my-alert',
buttons: ['Ok']
});
alert.present();
}
presentModal() {
let modal = this.modalCtrl.create(Modal);
modal.present();
}
goToPage2() {
this.navCtrl.push(Page2);
}
}
@Component({ templateUrl: 'modal.html' })
export class Modal {
constructor(public viewController: ViewController) { }
close() {
this.viewController.dismiss();
}
}
@Component({ templateUrl: 'page3.html' })
export class Page3 { }
@Component({ templateUrl: 'page2.html' })
export class Page2 {
constructor(public navCtrl: NavController) { }
page3() {
this.navCtrl.push(Page3);
}
}
@Component({
templateUrl: 'main.html'
})
export class E2EPage {
rootPage: any;
changeDetectionCount: number = 0;
pages: Array<{ title: string, component: any }>;
@ViewChild(Nav) nav: Nav;
constructor(public menuCtrl: MenuController) {
this.rootPage = Page1;
this.pages = [
{ title: 'Page 1', component: Page1 },
{ title: 'Page 2', component: Page2 },
{ title: 'Page 3', component: Page3 },
];
}
openPage(page: any) {
// Reset the content nav to have just this page
// we wouldn't want the back button to show in this scenario
this.nav.setRoot(page.component).then(() => {
// wait for the root page to be completely loaded
// then close the menu
this.menuCtrl.close();
});
}
openRightMenu() {
this.menuCtrl.open('right');
}
openLeftMenu() {
this.menuCtrl.open('left');
}
onDrag(ev: any) {
console.log('Menu is being dragged', ev);
}
onOpen(ev: any) {
console.log('Menu is open', ev);
}
onClose(ev: any) {
console.log('Menu is closed', ev);
}
isChangeDetecting() {
console.log('Change detection', ++this.changeDetectionCount);
return true;
}
}
@Component({
template: '<ion-nav [root]="rootPage"></ion-nav>'
})
export class E2EApp {
rootPage = E2EPage;
}
@NgModule({
declarations: [
E2EApp,
E2EPage,
Page1,
Page2,
Page3,
Modal
],
imports: [
BrowserModule,
IonicModule.forRoot(E2EApp)
],
bootstrap: [IonicApp],
entryComponents: [
E2EApp,
E2EPage,
Page1,
Page2,
Page3,
Modal
]
})
export class AppModule { }

View File

@ -0,0 +1,8 @@
import { Component } from '@angular/core';
@Component({
template: '<ion-nav [root]="rootPage"></ion-nav>'
})
export class E2EApp {
rootPage = 'E2EPage';
}

View File

@ -0,0 +1,30 @@
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { IonicApp, IonicModule } from '../../../../..';
import { Modal } from '../pages/modal/modal';
import { E2EApp } from './app.component';
@NgModule({
declarations: [
E2EApp,
Modal,
],
imports: [
BrowserModule,
IonicModule.forRoot(E2EApp, {}, {
links: [
{ loadChildren: '../pages/main/main.module#E2EPageModule', name: 'E2EPage' },
{ loadChildren: '../pages/page1/page1.module#Page1Module', name: 'Page1' },
{ loadChildren: '../pages/page2/page2.module#Page2Module', name: 'Page2' },
{ loadChildren: '../pages/page3/page3.module#Page3Module', name: 'Page3' },
]
})
],
bootstrap: [IonicApp],
entryComponents: [
E2EApp,
Modal,
]
})
export class AppModule { }

View File

@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { DeepLinkModule } from '../../../../../..';
import { E2EPage } from './main';
@NgModule({
declarations: [
E2EPage,
],
imports: [
DeepLinkModule.forChild(E2EPage)
],
entryComponents: [
E2EPage,
]
})
export class E2EPageModule {}

View File

@ -0,0 +1,58 @@
import { Component, ViewChild } from '@angular/core';
import { MenuController, Nav } from '../../../../../..';
@Component({
templateUrl: 'main.html'
})
export class E2EPage {
rootPage: any;
changeDetectionCount: number = 0;
pages: Array<{ title: string, component: any }>;
@ViewChild(Nav) nav: Nav;
constructor(public menuCtrl: MenuController) {
this.rootPage = 'Page1';
this.pages = [
{ title: 'Page 1', component: 'Page1' },
{ title: 'Page 2', component: 'Page2' },
{ title: 'Page 3', component: 'Page3' },
];
}
openPage(page: any) {
// Reset the content nav to have just this page
// we wouldn't want the back button to show in this scenario
this.nav.setRoot(page.component).then(() => {
// wait for the root page to be completely loaded
// then close the menu
this.menuCtrl.close();
});
}
openRightMenu() {
this.menuCtrl.open('right');
}
openLeftMenu() {
this.menuCtrl.open('left');
}
onDrag(ev: any) {
console.log('Menu is being dragged', ev);
}
onOpen(ev: any) {
console.log('Menu is open', ev);
}
onClose(ev: any) {
console.log('Menu is closed', ev);
}
isChangeDetecting() {
console.log('Change detection', ++this.changeDetectionCount);
return true;
}
}

View File

@ -0,0 +1,10 @@
import { Component } from '@angular/core';
import { ViewController } from '../../../../../..';
@Component({ templateUrl: 'modal.html' })
export class Modal {
constructor(public viewController: ViewController) { }
close() {
this.viewController.dismiss();
}
}

View File

@ -7,7 +7,7 @@
</button> </button>
<ion-title> <ion-title>
Menu Menu!!!!!!!!!
</ion-title> </ion-title>
<ion-buttons end> <ion-buttons end>

View File

@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { DeepLinkModule } from '../../../../../..';
import { Page1 } from './page1';
@NgModule({
declarations: [
Page1,
],
imports: [
DeepLinkModule.forChild(Page1)
],
entryComponents: [
Page1,
]
})
export class Page1Module {}

View File

@ -0,0 +1,35 @@
import { Component } from '@angular/core';
import { AlertController, ModalController, NavController } from '../../../../../..';
import { Modal } from '../modal/modal';
@Component({
templateUrl: 'page1.html'
})
export class Page1 {
constructor(
public navCtrl: NavController,
public alertCtrl: AlertController,
public modalCtrl: ModalController) { }
myMenu: string = 'right';
presentAlert() {
let alert = this.alertCtrl.create({
title: 'New Friend!',
message: 'Your friend, Obi wan Kenobi, just accepted your friend request!',
cssClass: 'my-alert',
buttons: ['Ok']
});
alert.present();
}
presentModal() {
let modal = this.modalCtrl.create(Modal);
modal.present();
}
goToPage2() {
this.navCtrl.push('Page2');
}
}

View File

@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { DeepLinkModule } from '../../../../../..';
import { Page2 } from './page2';
@NgModule({
declarations: [
Page2,
],
imports: [
DeepLinkModule.forChild(Page2)
],
entryComponents: [
Page2,
]
})
export class Page2Module {}

View File

@ -0,0 +1,11 @@
import { Component } from '@angular/core';
import { NavController } from '../../../../../..';
@Component({ templateUrl: 'page2.html' })
export class Page2 {
constructor(public navCtrl: NavController) { }
page3() {
this.navCtrl.push('Page3');
}
}

View File

@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { DeepLinkModule } from '../../../../../..';
import { Page3 } from './page3';
@NgModule({
declarations: [
Page3,
],
imports: [
DeepLinkModule.forChild(Page3)
],
entryComponents: [
Page3,
]
})
export class Page3Module {}

View File

@ -0,0 +1,4 @@
import { Component } from '@angular/core';
@Component({ templateUrl: 'page3.html' })
export class Page3 { }