Skip to content

Commit 0501bf3

Browse files
committed
test(renderer): tabview binding tests
1 parent 1d44679 commit 0501bf3

File tree

12 files changed

+130
-0
lines changed

12 files changed

+130
-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+

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

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

0 commit comments

Comments
 (0)