| 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 "base/mac/bind_objc_block.h" | 8 #include "base/mac/bind_objc_block.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 IDS_IOS_TAB_STRIP_LEAVE_TAB_SWITCHER); | 152 IDS_IOS_TAB_STRIP_LEAVE_TAB_SWITCHER); |
| 153 [[EarlGrey selectElementWithMatcher:matcher] performAction:grey_tap()]; | 153 [[EarlGrey selectElementWithMatcher:matcher] performAction:grey_tap()]; |
| 154 } | 154 } |
| 155 | 155 |
| 156 // Swithches to normal mode using swith button (iPad) or stack view (iPhone). | 156 // Swithches to normal mode using swith button (iPad) or stack view (iPhone). |
| 157 // Assumes current mode is Incognito. | 157 // Assumes current mode is Incognito. |
| 158 void SwitchToNormalMode() { | 158 void SwitchToNormalMode() { |
| 159 GREYAssertTrue(chrome_test_util::IsIncognitoMode(), | 159 GREYAssertTrue(chrome_test_util::IsIncognitoMode(), |
| 160 @"Switching to normal mode is only allowed from Incognito."); | 160 @"Switching to normal mode is only allowed from Incognito."); |
| 161 if (IsIPadIdiom()) { | 161 if (IsIPadIdiom()) { |
| 162 if (experimental_flags::IsTabSwitcherEnabled()) { | 162 // Enter the tab switcher. |
| 163 // Enter the tab switcher. | 163 id<GREYMatcher> tabSwitcherEnterButton = grey_accessibilityLabel( |
| 164 id<GREYMatcher> tabSwitcherEnterButton = | 164 l10n_util::GetNSStringWithFixup(IDS_IOS_TAB_STRIP_ENTER_TAB_SWITCHER)); |
| 165 grey_accessibilityLabel(l10n_util::GetNSStringWithFixup( | 165 [[EarlGrey selectElementWithMatcher:tabSwitcherEnterButton] |
| 166 IDS_IOS_TAB_STRIP_ENTER_TAB_SWITCHER)); | 166 performAction:grey_tap()]; |
| 167 [[EarlGrey selectElementWithMatcher:tabSwitcherEnterButton] | |
| 168 performAction:grey_tap()]; | |
| 169 | 167 |
| 170 // Select the non incognito panel. | 168 // Select the non incognito panel. |
| 171 id<GREYMatcher> tabSwitcherHeaderPanelButton = | 169 id<GREYMatcher> tabSwitcherHeaderPanelButton = |
| 172 grey_accessibilityLabel(l10n_util::GetNSStringWithFixup( | 170 grey_accessibilityLabel(l10n_util::GetNSStringWithFixup( |
| 173 IDS_IOS_TAB_SWITCHER_HEADER_NON_INCOGNITO_TABS)); | 171 IDS_IOS_TAB_SWITCHER_HEADER_NON_INCOGNITO_TABS)); |
| 174 [[EarlGrey selectElementWithMatcher:tabSwitcherHeaderPanelButton] | 172 [[EarlGrey selectElementWithMatcher:tabSwitcherHeaderPanelButton] |
| 175 performAction:grey_tap()]; | 173 performAction:grey_tap()]; |
| 176 | 174 |
| 177 // Leave the tab switcher. | 175 // Leave the tab switcher. |
| 178 CloseTabSwitcher(); | 176 CloseTabSwitcher(); |
| 179 } else { | |
| 180 [[EarlGrey selectElementWithMatcher: | |
| 181 chrome_test_util::ButtonWithAccessibilityLabelId( | |
| 182 IDS_IOS_SWITCH_BROWSER_MODE_LEAVE_INCOGNITO)] | |
| 183 performAction:grey_tap()]; | |
| 184 } | |
| 185 } else { | 177 } else { |
| 186 [[EarlGrey selectElementWithMatcher: | 178 [[EarlGrey selectElementWithMatcher: |
| 187 chrome_test_util::ButtonWithAccessibilityLabelId( | 179 chrome_test_util::ButtonWithAccessibilityLabelId( |
| 188 IDS_IOS_TOOLBAR_SHOW_TABS)] performAction:grey_tap()]; | 180 IDS_IOS_TOOLBAR_SHOW_TABS)] performAction:grey_tap()]; |
| 189 [[EarlGrey selectElementWithMatcher: | 181 [[EarlGrey selectElementWithMatcher: |
| 190 chrome_test_util::ButtonWithAccessibilityLabelId( | 182 chrome_test_util::ButtonWithAccessibilityLabelId( |
| 191 IDS_IOS_TOOLS_MENU_NEW_INCOGNITO_TAB)] | 183 IDS_IOS_TOOLS_MENU_NEW_INCOGNITO_TAB)] |
| 192 performAction:grey_swipeSlowInDirection(kGREYDirectionRight)]; | 184 performAction:grey_swipeSlowInDirection(kGREYDirectionRight)]; |
| 193 [[EarlGrey selectElementWithMatcher: | 185 [[EarlGrey selectElementWithMatcher: |
| 194 chrome_test_util::ButtonWithAccessibilityLabelId( | 186 chrome_test_util::ButtonWithAccessibilityLabelId( |
| (...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 948 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; | 940 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; |
| 949 } | 941 } |
| 950 // The deleted tabs are purged during foregrounding and backgrounding. | 942 // The deleted tabs are purged during foregrounding and backgrounding. |
| 951 chrome_test_util::SimulateTabsBackgrounding(); | 943 chrome_test_util::SimulateTabsBackgrounding(); |
| 952 // Make sure |evicted_tabs_| purged the deleted tabs. | 944 // Make sure |evicted_tabs_| purged the deleted tabs. |
| 953 int evicted = chrome_test_util::GetEvictedMainTabCount(); | 945 int evicted = chrome_test_util::GetEvictedMainTabCount(); |
| 954 GREYAssertEqual(evicted, 0, @"Check number of evicted tabs"); | 946 GREYAssertEqual(evicted, 0, @"Check number of evicted tabs"); |
| 955 } | 947 } |
| 956 | 948 |
| 957 @end | 949 @end |
| OLD | NEW |