Chromium Code Reviews| 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 <XCTest/XCTest.h> | 5 #import <XCTest/XCTest.h> |
| 6 | 6 |
| 7 #include "base/ios/block_types.h" | 7 #include "base/ios/block_types.h" |
| 8 #include "base/mac/foundation_util.h" | 8 #include "base/mac/foundation_util.h" |
| 9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 10 #import "base/test/ios/wait_util.h" | 10 #import "base/test/ios/wait_util.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 descriptionBlock:describe]; | 45 descriptionBlock:describe]; |
| 46 } | 46 } |
| 47 | 47 |
| 48 // Returns a matcher for the StackViewController's view. | 48 // Returns a matcher for the StackViewController's view. |
| 49 id<GREYMatcher> StackView() { | 49 id<GREYMatcher> StackView() { |
| 50 return ViewMatchingView([chrome_test_util::GetStackViewController() view]); | 50 return ViewMatchingView([chrome_test_util::GetStackViewController() view]); |
| 51 } | 51 } |
| 52 | 52 |
| 53 // Waits for the Stack View to be visible/hidden. | 53 // Waits for the Stack View to be visible/hidden. |
| 54 void CheckForStackViewVisibility(bool visible) { | 54 void CheckForStackViewVisibility(bool visible) { |
| 55 // Wait for the tab switcher to be active or inactive. | |
| 56 NSString* activeTabSwitcherDescription = | |
| 57 [NSString stringWithFormat:@"Waiting for tab switcher to be %@.", | |
| 58 visible ? @"active" : @"inactive"]; | |
|
Eugene But (OOO till 7-30)
2017/02/23 19:11:25
I'm confused about mixing is_visible and is_active
kkhorimoto
2017/03/07 06:46:51
separated out into two different checks.
| |
| 59 BOOL (^activeTabSwitcherBlock) | |
| 60 () = ^BOOL { | |
|
Eugene But (OOO till 7-30)
2017/02/23 19:11:25
Is this done by clang format? If so, could you ple
kkhorimoto
2017/03/07 06:46:51
Done.
| |
| 61 BOOL isActive = chrome_test_util::GetStackViewController() != nil && | |
|
Eugene But (OOO till 7-30)
2017/02/23 19:11:25
nit: no need for |!= nil|
kkhorimoto
2017/03/07 06:46:51
Done.
| |
| 62 chrome_test_util::IsTabSwitcherActive(); | |
| 63 return visible ? isActive : !isActive; | |
| 64 }; | |
| 65 GREYCondition* activeTabSwitcherCondition = | |
| 66 [GREYCondition conditionWithName:activeTabSwitcherDescription | |
| 67 block:activeTabSwitcherBlock]; | |
| 68 [activeTabSwitcherCondition waitWithTimeout:5.0]; | |
|
Eugene But (OOO till 7-30)
2017/02/23 19:11:25
Do you want to use kWaitForUIElementTimeout instea
kkhorimoto
2017/03/07 06:46:51
Done.
| |
| 69 // Verify the visibility of the stack view. | |
| 55 id<GREYMatcher> visibilityMatcher = | 70 id<GREYMatcher> visibilityMatcher = |
| 56 grey_allOf(visible ? grey_sufficientlyVisible() : grey_notVisible(), | 71 grey_allOf(visible ? grey_sufficientlyVisible() : grey_notVisible(), |
| 57 visible ? grey_notNil() : grey_nil(), nil); | 72 visible ? grey_notNil() : grey_nil(), nil); |
| 58 [[EarlGrey selectElementWithMatcher:StackView()] | 73 [[EarlGrey selectElementWithMatcher:StackView()] |
| 59 assertWithMatcher:visibilityMatcher]; | 74 assertWithMatcher:visibilityMatcher]; |
| 60 } | 75 } |
| 61 | 76 |
| 62 // Opens the StackViewController. | 77 // Opens the StackViewController. |
| 63 void OpenStackView() { | 78 void OpenStackView() { |
| 64 if (chrome_test_util::IsTabSwitcherActive()) | 79 if (chrome_test_util::IsTabSwitcherActive()) |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 180 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(identifier)] | 195 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(identifier)] |
| 181 performAction:grey_tap()]; | 196 performAction:grey_tap()]; |
| 182 // Verify that the CardView and its associated Tab were removed. | 197 // Verify that the CardView and its associated Tab were removed. |
| 183 [[EarlGrey selectElementWithMatcher:ViewMatchingView(cardView)] | 198 [[EarlGrey selectElementWithMatcher:ViewMatchingView(cardView)] |
| 184 assertWithMatcher:grey_notVisible()]; | 199 assertWithMatcher:grey_notVisible()]; |
| 185 GREYAssertEqual(chrome_test_util::GetMainTabCount(), 0, | 200 GREYAssertEqual(chrome_test_util::GetMainTabCount(), 0, |
| 186 @"All Tabs should be closed."); | 201 @"All Tabs should be closed."); |
| 187 } | 202 } |
| 188 | 203 |
| 189 // Tests closing all Tabs in the stack view. | 204 // Tests closing all Tabs in the stack view. |
| 190 // TODO(crbug.com/693517): Re-enable this test on simulator. | 205 - (void)testCloseAllTabs { |
| 191 #if TARGET_IPHONE_SIMULATOR | |
| 192 #define MAYBE_testCloseAllTabs FLAKY_testCloseAllTabs | |
| 193 #else | |
| 194 #define MAYBE_testCloseAllTabs testCloseAllTabs | |
| 195 #endif | |
| 196 - (void)MAYBE_testCloseAllTabs { | |
| 197 // The StackViewController is only used on iPhones. | 206 // The StackViewController is only used on iPhones. |
| 198 if (IsIPadIdiom()) | 207 if (IsIPadIdiom()) |
| 199 EARL_GREY_TEST_SKIPPED(@"Stack view is not used on iPads."); | 208 EARL_GREY_TEST_SKIPPED(@"Stack view is not used on iPads."); |
| 200 // Open an incognito Tab. | 209 // Open an incognito Tab. |
| 201 OpenNewIncognitoTabUsingStackView(); | 210 OpenNewIncognitoTabUsingStackView(); |
| 202 GREYAssertEqual(chrome_test_util::GetIncognitoTabCount(), 1, | 211 GREYAssertEqual(chrome_test_util::GetIncognitoTabCount(), 1, |
| 203 @"Incognito Tab was not opened."); | 212 @"Incognito Tab was not opened."); |
| 204 // Open two additional Tabs. | 213 // Open two additional Tabs. |
| 205 const NSUInteger kAdditionalTabCount = 2; | 214 const NSUInteger kAdditionalTabCount = 2; |
| 206 for (NSUInteger i = 0; i < kAdditionalTabCount; ++i) | 215 for (NSUInteger i = 0; i < kAdditionalTabCount; ++i) |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 250 chrome_test_util::GetStackViewController(); | 259 chrome_test_util::GetStackViewController(); |
| 251 GREYAssert([stackViewController isCurrentSetIncognito], | 260 GREYAssert([stackViewController isCurrentSetIncognito], |
| 252 @"Incognito deck not selected."); | 261 @"Incognito deck not selected."); |
| 253 // Switch back to the main CardSet and verify that is selected. | 262 // Switch back to the main CardSet and verify that is selected. |
| 254 ShowDeckWithType(DeckType::NORMAL); | 263 ShowDeckWithType(DeckType::NORMAL); |
| 255 GREYAssert(![stackViewController isCurrentSetIncognito], | 264 GREYAssert(![stackViewController isCurrentSetIncognito], |
| 256 @"Normal deck not selected."); | 265 @"Normal deck not selected."); |
| 257 } | 266 } |
| 258 | 267 |
| 259 @end | 268 @end |
| OLD | NEW |