| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import <EarlGrey/EarlGrey.h> | 5 #import <EarlGrey/EarlGrey.h> |
| 6 #import <XCTest/XCTest.h> | 6 #import <XCTest/XCTest.h> |
| 7 | 7 |
| 8 #include "ios/chrome/browser/experimental_flags.h" | 8 #include "ios/chrome/browser/experimental_flags.h" |
| 9 #import "ios/chrome/browser/ui/tabs/tab_view.h" | 9 #import "ios/chrome/browser/ui/tabs/tab_view.h" |
| 10 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 10 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 grey_ancestor(grey_equalTo(tabView)), | 48 grey_ancestor(grey_equalTo(tabView)), |
| 49 grey_accessibilityID(@"Favicon"), nil)] | 49 grey_accessibilityID(@"Favicon"), nil)] |
| 50 performAction:grey_tap()]; | 50 performAction:grey_tap()]; |
| 51 | 51 |
| 52 Tab* newCurrentTab = chrome_test_util::GetCurrentTab(); | 52 Tab* newCurrentTab = chrome_test_util::GetCurrentTab(); |
| 53 GREYAssertTrue(newCurrentTab == nextTab, | 53 GREYAssertTrue(newCurrentTab == nextTab, |
| 54 @"The selected tab did not change to the next tab."); | 54 @"The selected tab did not change to the next tab."); |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 | 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 | 58 @end |
| OLD | NEW |