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