Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6028514

Browse files
authored
Merge pull request #279 from NativeScript/hdeshev/appium
Add appium E2E tests for the router
2 parents ab3ff84 + b3b8a8e commit 6028514

26 files changed

+411
-321
lines changed

‎.travis.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,4 @@ before_script:
3939
script:
4040
- tns platform add android
4141
- tns test android --emulator --justlaunch
42+
- npm run appium-android

‎nativescript-angular/application.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import "zone.js/dist/zone-node"
33

44
import 'reflect-metadata';
55
import './polyfills/array';
6+
import {rendererLog, rendererError} from "./trace";
67
import {SanitizationService} from '@angular/core/src/security';
78
import {isPresent, Type, print} from '@angular/core/src/facade/lang';
89
import {ReflectiveInjector, reflector, coreLoadAndBootstrap, createPlatform,
@@ -107,18 +108,18 @@ export function nativeScriptBootstrap(appComponentType: any, customProviders?: P
107108
let onLoadedHandler = function(args) {
108109
page.off('loaded', onLoadedHandler);
109110
//profiling.stop('application-start');
110-
console.log('Page loaded');
111+
rendererLog('Page loaded');
111112

112113
//profiling.start('ng-bootstrap');
113-
console.log('BOOTSTRAPPING...');
114+
rendererLog('BOOTSTRAPPING...');
114115
bootstrap(appComponentType, customProviders).then((appRef) => {
115116
//profiling.stop('ng-bootstrap');
116-
console.log('ANGULAR BOOTSTRAP DONE.');
117+
rendererLog('ANGULAR BOOTSTRAP DONE.');
117118
resolve(appRef);
118119
}, (err) => {
119-
console.log('ERROR BOOTSTRAPPING ANGULAR');
120+
rendererError('ERROR BOOTSTRAPPING ANGULAR');
120121
let errorMessage = err.message + "\n\n" + err.stack;
121-
console.log(errorMessage);
122+
rendererError(errorMessage);
122123

123124
let view = new TextView();
124125
view.text = errorMessage;

‎nativescript-angular/directives/list-view-comp.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {View} from 'ui/core/view';
2222
import {NgView} from '../view-util';
2323
import {ObservableArray} from 'data/observable-array';
2424
import {LayoutBase} from 'ui/layouts/layout-base';
25+
import {rendererLog, rendererError} from "../trace";
2526
const NG_VIEW = "_ngViewRef";
2627

2728
export class ListItemContext {
@@ -98,15 +99,15 @@ export class ListViewComponent {
9899
let viewRef: EmbeddedViewRef<ListItemContext>;
99100

100101
if (args.view) {
101-
console.log("ListView.onItemLoading: " + index + " - Reusing existing view");
102+
rendererLog("ListView.onItemLoading: " + index + " - Reusing existing view");
102103
viewRef = args.view[NG_VIEW];
103104
// getting angular view from original element (in cases when ProxyViewContainer is used NativeScript internally wraps it in a StackLayout)
104105
if (!viewRef) {
105106
viewRef = (args.view._subViews && args.view._subViews.length > 0) ? args.view._subViews[0][NG_VIEW] : undefined;
106107
}
107108
}
108109
else {
109-
console.log("ListView.onItemLoading: " + index + " - Creating view from template");
110+
rendererLog("ListView.onItemLoading: " + index + " - Creating view from template");
110111
viewRef = this.loader.createEmbeddedView(this.itemTemplate, new ListItemContext(), 0);
111112
args.view = getSingleViewFromViewRef(viewRef);
112113
args.view[NG_VIEW] = viewRef;

‎nativescript-angular/directives/tab-view.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {ElementRef, Directive, Input, TemplateRef, ViewContainerRef} from "@angular/core";
22
import {TabView, TabViewItem} from "ui/tab-view";
33
import * as utils from '../common/utils';
4+
import {rendererLog, rendererError} from "../trace";
45
import {isBlank} from '@angular/core/src/facade/lang';
56

67
@Directive({
@@ -31,7 +32,7 @@ export class TabViewDirective {
3132
ngAfterViewInit() {
3233
this.viewInitialized = true;
3334
debugger;
34-
console.log("this._selectedIndex: " + this._selectedIndex);
35+
rendererLog("this._selectedIndex: " + this._selectedIndex);
3536
if (!isBlank(this._selectedIndex)) {
3637
this.tabView.selectedIndex = this._selectedIndex;
3738
}

‎nativescript-angular/dom_adapter.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {SanitizationService} from '@angular/core/src/security';
33
import {Parse5DomAdapter} from '@angular/platform-server';
44
import {setRootDomAdapter} from '@angular/platform-browser/src/dom/dom_adapter';
55
import {Type} from '@angular/core/src/facade/lang';
6+
import {rendererLog, rendererError} from "./trace";
67

78
export enum SecurityContext {
89
NONE,
@@ -35,7 +36,7 @@ export class NativeScriptSanitizationService extends SanitizationService {
3536

3637
export class NativeScriptDomAdapter extends Parse5DomAdapter {
3738
static makeCurrent() {
38-
console.log("Setting DOM");
39+
rendererLog("Setting DOM");
3940
setRootDomAdapter(new NativeScriptDomAdapter());
4041
}
4142

‎nativescript-angular/renderer.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ import {View} from "ui/core/view";
1212
import * as application from "application";
1313
import {topmost} from 'ui/frame';
1414
import {Page} from 'ui/page';
15-
import {traceLog, ViewUtil, NgView} from "./view-util";
15+
import {ViewUtil, NgView} from "./view-util";
16+
import {rendererLog as traceLog} from "./trace";
1617
import {escapeRegexSymbols} from "utils/utils";
1718
import { Device } from "platform";
1819

19-
export { rendererTraceCategory } from "./view-util";
20-
2120
@Injectable()
2221
export class NativeScriptRootRenderer implements RootRenderer {
2322
private _rootView: View = null;

‎nativescript-angular/router/common.ts‎

Lines changed: 0 additions & 7 deletions
This file was deleted.

‎nativescript-angular/router/ns-location-strategy.ts‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import application = require("application");
22
import { LocationStrategy } from '@angular/common';
33
import { NgZone, ApplicationRef, Inject, forwardRef } from '@angular/core';
4-
import { log } from "./common";
4+
import { routerLog } from "../trace";
55
import { topmost } from "ui/frame";
66

77
interface LocationState {
@@ -20,18 +20,18 @@ export class NSLocationStrategy extends LocationStrategy {
2020
private _isPageNavigatingForward: boolean = false;
2121

2222
path(): string {
23-
log("NSLocationStrategy.path()");
23+
routerLog("NSLocationStrategy.path()");
2424
let state = this.peekState();
2525
return state ? state.url : "/";
2626
}
2727

2828
prepareExternalUrl(internal: string): string {
29-
log("NSLocationStrategy.prepareExternalUrl() internal: " + internal);
29+
routerLog("NSLocationStrategy.prepareExternalUrl() internal: " + internal);
3030
return internal;
3131
}
3232

3333
pushState(state: any, title: string, url: string, queryParams: string): void {
34-
log(`NSLocationStrategy.pushState state: ${state}, title: ${title}, url: ${url}, queryParams: ${queryParams}`);
34+
routerLog(`NSLocationStrategy.pushState state: ${state}, title: ${title}, url: ${url}, queryParams: ${queryParams}`);
3535

3636
let isNewPage = this._isPageNavigatingForward;
3737
this._isPageNavigatingForward = false;
@@ -46,12 +46,12 @@ export class NSLocationStrategy extends LocationStrategy {
4646
}
4747

4848
replaceState(state: any, title: string, url: string, queryParams: string): void {
49-
log(`NSLocationStrategy.replaceState state: ${state}, title: ${title}, url: ${url}, queryParams: ${queryParams}`);
49+
routerLog(`NSLocationStrategy.replaceState state: ${state}, title: ${title}, url: ${url}, queryParams: ${queryParams}`);
5050
throw new Error("Not implemented");
5151
}
5252

5353
forward(): void {
54-
log("NSLocationStrategy.forward");
54+
routerLog("NSLocationStrategy.forward");
5555
throw new Error("Not implemented");
5656
}
5757

@@ -65,30 +65,30 @@ export class NSLocationStrategy extends LocationStrategy {
6565
state = this.states.pop();
6666
count++;
6767
}
68-
log("NSLocationStrategy.back() while navigating back. States popped: " + count)
68+
routerLog("NSLocationStrategy.back() while navigating back. States popped: " + count)
6969
this.callPopState(state, true);
7070
} else {
7171
let state = this.peekState();
7272
if (state.isPageNavigation) {
7373
// This was a page navigation - so navigate through frame.
74-
log("NSLocationStrategy.back() while not navigating back but top state is page - will call frame.goback()")
74+
routerLog("NSLocationStrategy.back() while not navigating back but top state is page - will call frame.goback()")
7575
topmost().goBack();
7676
} else {
7777
// Nested navigation - just pop the state
78-
log("NSLocationStrategy.back() while not navigating back but top state is not page - just pop")
78+
routerLog("NSLocationStrategy.back() while not navigating back but top state is not page - just pop")
7979
this.callPopState(this.states.pop(), true);
8080
}
8181
}
8282

8383
}
8484

8585
onPopState(fn: (_: any) => any): void {
86-
log("NSLocationStrategy.onPopState");
86+
routerLog("NSLocationStrategy.onPopState");
8787
this.popStateCallbacks.push(fn);
8888
}
8989

9090
getBaseHref(): string {
91-
log("NSLocationStrategy.getBaseHref()");
91+
routerLog("NSLocationStrategy.getBaseHref()");
9292
return "";
9393
}
9494

@@ -108,15 +108,15 @@ export class NSLocationStrategy extends LocationStrategy {
108108

109109
// Methods for syncing with page navigation in PageRouterOutlet
110110
public beginBackPageNavigation() {
111-
log("NSLocationStrategy.startGoBack()");
111+
routerLog("NSLocationStrategy.startGoBack()");
112112
if (this._isPageNavigationgBack) {
113113
throw new Error("Calling startGoBack while going back.")
114114
}
115115
this._isPageNavigationgBack = true;
116116
}
117117

118118
public finishBackPageNavigation() {
119-
log("NSLocationStrategy.finishBackPageNavigation()");
119+
routerLog("NSLocationStrategy.finishBackPageNavigation()");
120120
if (!this._isPageNavigationgBack) {
121121
throw new Error("Calling endGoBack while not going back.")
122122
}
@@ -128,7 +128,7 @@ export class NSLocationStrategy extends LocationStrategy {
128128
}
129129

130130
public navigateToNewPage() {
131-
log("NSLocationStrategy.navigateToNewPage()");
131+
routerLog("NSLocationStrategy.navigateToNewPage()");
132132
if (this._isPageNavigatingForward) {
133133
throw new Error("Calling navigateToNewPage while already navigating to new page.")
134134
}

‎nativescript-angular/router/ns-router-link.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {Directive, Input} from '@angular/core';
22
import {isString} from '@angular/core/src/facade/lang';
33
import {Router, Instruction} from '@angular/router-deprecated';
4-
import {log} from "./common";
4+
import {routerLog} from "../trace";
55

66
/**
77
* The NSRouterLink directive lets you link to specific parts of your app.
@@ -55,7 +55,7 @@ export class NSRouterLink {
5555
}
5656

5757
onTap(): void {
58-
log("NSRouterLink onTap() instruction: " + JSON.stringify(this._navigationInstruction))
58+
routerLog("NSRouterLink onTap() instruction: " + JSON.stringify(this._navigationInstruction))
5959
this._router.navigateByInstruction(this._navigationInstruction);
6060
}
6161
}

‎nativescript-angular/router/ns-router.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {NSLocationStrategy} from './ns-location-strategy';
55
import {ROUTER_PROVIDERS} from '@angular/router-deprecated';
66
import {LocationStrategy} from '@angular/common';
77
import {provide} from '@angular/core';
8-
import{CATEGORY} from "./common";
8+
export{routerTraceCategory} from "../trace";
99

1010
export const NS_ROUTER_PROVIDERS: any[] = [
1111
ROUTER_PROVIDERS,
@@ -17,5 +17,3 @@ export const NS_ROUTER_DIRECTIVES: Type[] = [
1717
NSRouterLink,
1818
PageRouterOutlet
1919
];
20-
21-
export const routerTraceCategory = CATEGORY;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /