Skip to content

Commit 8af113c

Browse files
committed
test(renderer): tabview binding tests
1 parent 1d44679 commit 8af113c

24 files changed

+138
-0
lines changed
Loading
Loading
441 Bytes
Loading
754 Bytes
Loading
929 Bytes
Loading

Diff for: e2e/renderer/app/App_Resources/iOS/tabIcons/home.png

383 Bytes
Loading
681 Bytes
Loading
981 Bytes
Loading

Diff for: e2e/renderer/app/app-routing.module.ts

+8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { NativeScriptRouterModule } from "nativescript-angular/router";
44
import { ActionBarDynamicItemsComponent } from "./action-bar/action-bar-dynamic-items.component";
55
import { ActionBarExtensionComponent } from "./action-bar/action-bar-extension.component";
66

7+
import { TabItemBindingComponent } from "./tab-view/tab-item-binding.component";
8+
79
import { ListComponent } from "./list.component";
810
import { NgForComponent } from "./ngfor.component";
911
import { NgForOfComponent } from "./ngforof.component";
@@ -28,6 +30,10 @@ export const routes = [
2830
path: "action-bar-extension",
2931
component: ActionBarExtensionComponent,
3032
},
33+
{
34+
path: "tab-item-binding",
35+
component: TabItemBindingComponent,
36+
},
3137
{
3238
path: "list",
3339
component: ListComponent,
@@ -70,6 +76,8 @@ export const navigatableComponents = [
7076
ActionBarDynamicItemsComponent,
7177
ActionBarExtensionComponent,
7278

79+
TabItemBindingComponent,
80+
7381
ListComponent,
7482
NgForComponent,
7583
NgForOfComponent,

Diff for: e2e/renderer/app/list.component.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Component } from "@angular/core";
55
<FlexboxLayout flexDirection="column">
66
<Button text="ActionBar dynamic" [nsRouterLink]="['/action-bar-dynamic']"></Button>
77
<Button text="ActionBarExtension" [nsRouterLink]="['/action-bar-extension']"></Button>
8+
<Button text="TabItem Binding" [nsRouterLink]="['/tab-item-binding']"></Button>
89
<Button text="NgFor" [nsRouterLink]="['/ngfor']"></Button>
910
<Button text="NgForOf" [nsRouterLink]="['/ngforof']"></Button>
1011
<Button text="NgIf no layout" [nsRouterLink]="['/ngif-no-layout']"></Button>
+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { Component } from "@angular/core";
2+
import { isAndroid } from "platform";
3+
4+
function getIconSource(icon: string): string {
5+
const iconPrefix = isAndroid ? "res://" : "res://tabIcons/";
6+
7+
return iconPrefix + icon;
8+
}
9+
10+
const notSelected = {
11+
title: "Not Selected",
12+
textTransform: "lowercase",
13+
iconSource: getIconSource("home")
14+
};
15+
16+
const selected = {
17+
title: "Selected",
18+
textTransform: "uppercase",
19+
iconSource: getIconSource("browse")
20+
};
21+
22+
@Component({
23+
template: `
24+
<ActionBar title="Tab Item Binding"></ActionBar>
25+
26+
<TabView (selectedIndexChange)="onIndexChange($event)">
27+
<GridLayout *tabItem="items[0]">
28+
<Label text="First Tab"></Label>
29+
</GridLayout>
30+
<GridLayout *tabItem="items[1]">
31+
<Label text="Second Tab"></Label>
32+
</GridLayout>
33+
<GridLayout *tabItem="items[2]">
34+
<Label text="Third Tab"></Label>
35+
</GridLayout>
36+
</TabView>
37+
`
38+
})
39+
export class TabItemBindingComponent {
40+
public items = [
41+
notSelected,
42+
notSelected,
43+
notSelected
44+
];
45+
46+
onIndexChange(args): void {
47+
const selectedIndex = args.object.selectedIndex;
48+
49+
for (let i = 0; i < this.items.length; i++) {
50+
this.items[i] = notSelected;
51+
}
52+
53+
this.items[selectedIndex] = selected;
54+
}
55+
}
56+
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

Diff for: e2e/renderer/e2e/tab-view.e2e-spec.ts

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import {
2+
AppiumDriver,
3+
createDriver,
4+
SearchOptions,
5+
UIElement
6+
} from "nativescript-dev-appium";
7+
import { assert } from "chai";
8+
9+
describe("TabView-scenario", () => {
10+
let driver: AppiumDriver;
11+
12+
describe("dynamically change TabView item title, icon and textTransform", async () => {
13+
let firstTabItem: UIElement;
14+
let secondTabItem: UIElement;
15+
let thirdTabItem: UIElement;
16+
17+
before(async () => {
18+
driver = await createDriver();
19+
await driver.driver.resetApp();
20+
});
21+
22+
it("should navigate to page", async () => {
23+
const navigationButton =
24+
await driver.findElementByText("TabItem Binding", SearchOptions.exact);
25+
await navigationButton.click();
26+
27+
await driver.findElementByText("Tab Item Binding", SearchOptions.exact);
28+
});
29+
30+
it("should find elements", async () => {
31+
await driver.findElementByText("First Tab");
32+
33+
const notSelectedTabItems = await driver.findElementsByText("not selected");
34+
35+
firstTabItem = await driver.findElementByText("SELECTED");
36+
secondTabItem = notSelectedTabItems[0];
37+
thirdTabItem = notSelectedTabItems[1];
38+
39+
const screenMatches = await driver.compareScreen("tab-view-binding-first-tab", 5);
40+
assert(screenMatches);
41+
});
42+
43+
it("should navigate to second tab item", async () => {
44+
await secondTabItem.click();
45+
46+
await driver.findElementByText("Second Tab");
47+
48+
const notSelectedTabItems = await driver.findElementsByText("not selected");
49+
50+
firstTabItem = notSelectedTabItems[0];
51+
secondTabItem = await driver.findElementByText("SELECTED");
52+
thirdTabItem = notSelectedTabItems[1];
53+
54+
const screenMatches = await driver.compareScreen("tab-view-binding-second-tab", 5);
55+
assert(screenMatches);
56+
});
57+
58+
it("should navigate to third tab item", async () => {
59+
await thirdTabItem.click();
60+
61+
await driver.findElementByText("Third Tab");
62+
63+
const notSelectedTabItems = await driver.findElementsByText("not selected");
64+
65+
firstTabItem = notSelectedTabItems[0];
66+
secondTabItem = notSelectedTabItems[1];
67+
thirdTabItem = await driver.findElementByText("SELECTED");
68+
69+
const screenMatches = await driver.compareScreen("tab-view-binding-third-tab", 5);
70+
assert(screenMatches);
71+
});
72+
});
73+
});

0 commit comments

Comments
 (0)