Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: ios/chrome/browser/ui/tabs/tab_strip_egtest.mm

Issue 2588733002: Upstream Chrome on iOS source code [9/11]. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import <EarlGrey/EarlGrey.h>
6 #import <XCTest/XCTest.h>
7
8 #include "ios/chrome/browser/experimental_flags.h"
9 #import "ios/chrome/browser/ui/tabs/tab_view.h"
10 #import "ios/chrome/browser/ui/uikit_ui_util.h"
11 #include "ios/chrome/grit/ios_strings.h"
12 #import "ios/chrome/test/app/tab_test_util.h"
13 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
14 #import "ios/chrome/test/earl_grey/chrome_test_case.h"
15 #include "ui/base/l10n/l10n_util.h"
16
17 // Tests for the tab strip shown on iPad.
18 @interface TabStripTestCase : ChromeTestCase
19 @end
20
21 @implementation TabStripTestCase
22
23 // Test switching tabs using the tab strip.
24 - (void)testTabStripSwitchTabs {
25 // Only iPad has a tab strip.
26 if (IsCompact()) {
27 return;
28 }
29
30 // TODO(crbug.com/238112): Make this test also handle the 'collapsed' tab
31 // case.
32 const int kNumberOfTabs = 3;
33 for (int i = 0; i < kNumberOfTabs - 1; i++) {
34 [ChromeEarlGreyUI openNewTab];
35 }
36
37 // Note that the tab ordering wraps. E.g. if A, B, and C are open,
38 // and C is the current tab, the 'next' tab is 'A'.
39 for (int i = 0; i < kNumberOfTabs + 1; i++) {
40 GREYAssertTrue(chrome_test_util::GetMainTabCount() > 1,
41 chrome_test_util::GetMainTabCount() ? @"Only one tab open."
42 : @"No more tabs.");
43 Tab* nextTab = chrome_test_util::GetNextTab();
44 TabView* tabView = chrome_test_util::GetTabViewForTab(nextTab);
45
46 [[EarlGrey
47 selectElementWithMatcher:grey_allOf(
48 grey_ancestor(grey_equalTo(tabView)),
49 grey_accessibilityID(@"Favicon"), nil)]
50 performAction:grey_tap()];
51
52 Tab* newCurrentTab = chrome_test_util::GetCurrentTab();
53 GREYAssertTrue(newCurrentTab == nextTab,
54 @"The selected tab did not change to the next tab.");
55 }
56 }
57
58 // Tests switching the mode using the mode toggle.
59 - (void)testTabStripSwitchModes {
60 // The toggle button only exists on iPad, and when the Tablet Tab Switcher
61 // isn't enabled.
62 if (IsCompact() || experimental_flags::IsTabSwitcherEnabled()) {
63 return;
64 }
65
66 // Open two normal tabs.
67 [ChromeEarlGreyUI openNewTab];
68 [ChromeEarlGreyUI openNewTab];
69
70 // Open two incognito tabs.
71 [ChromeEarlGreyUI openNewIncognitoTab];
72 [ChromeEarlGreyUI openNewIncognitoTab];
73
74 // Switch back to normal mode.
75 [[EarlGrey selectElementWithMatcher:
76 grey_accessibilityLabel(l10n_util::GetNSString(
77 IDS_IOS_SWITCH_BROWSER_MODE_LEAVE_INCOGNITO))]
78 performAction:grey_tap()];
79 GREYAssertFalse(chrome_test_util::IsIncognitoMode(),
80 @"Current tab is incognito.");
81
82 // Switch back to incognito mode.
83 [[EarlGrey selectElementWithMatcher:
84 grey_accessibilityLabel(l10n_util::GetNSString(
85 IDS_IOS_SWITCH_BROWSER_MODE_ENTER_INCOGNITO))]
86 performAction:grey_tap()];
87 GREYAssertTrue(chrome_test_util::IsIncognitoMode(),
88 @"Current tab is not incognito.");
89
90 // Close both incognito tabs.
91 chrome_test_util::CloseAllTabsInCurrentMode();
92
93 // We should be in normal mode.
94 GREYAssertFalse(chrome_test_util::IsIncognitoMode(),
95 @"Current tab is incognito.");
96
97 // There should be no incognito switch.
98 [[EarlGrey selectElementWithMatcher:
99 grey_accessibilityID(l10n_util::GetNSString(
100 IDS_IOS_SWITCH_BROWSER_MODE_ENTER_INCOGNITO))]
101 assertWithMatcher:grey_notVisible()];
102 }
103
104 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/tabs/tab_strip_controller_unittest.mm ('k') | ios/chrome/browser/ui/tabs/tab_strip_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698