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

Unified Diff: ios/chrome/browser/ui/stack_view/stack_view_egtest.mm

Issue 2706403006: Check that tab switcher is active/inactive before visibility check. (Closed)
Patch Set: fix gn Created 3 years, 9 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/browser/ui/stack_view/BUILD.gn ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/stack_view/stack_view_egtest.mm
diff --git a/ios/chrome/browser/ui/stack_view/stack_view_egtest.mm b/ios/chrome/browser/ui/stack_view/stack_view_egtest.mm
index 6d2f88fcccce4ea72a79d2f603bd590b1b6bd6a0..ea01d1bf09f07bea88ffb22718e0d04af4ce9e07 100644
--- a/ios/chrome/browser/ui/stack_view/stack_view_egtest.mm
+++ b/ios/chrome/browser/ui/stack_view/stack_view_egtest.mm
@@ -24,6 +24,7 @@
#import "ios/chrome/test/earl_grey/chrome_matchers.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.h"
#include "ios/testing/earl_grey/disabled_test_macros.h"
+#import "ios/testing/wait_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
@@ -50,7 +51,30 @@
return ViewMatchingView([chrome_test_util::GetStackViewController() view]);
}
-// Waits for the Stack View to be visible/hidden.
+// Waits for the Stack View to be active/inactive.
+void WaitForStackViewActive(bool active) {
+ NSString* activeStatusString = active ? @"active" : @"inactive";
+ NSString* activeTabSwitcherDescription =
+ [NSString stringWithFormat:@"Waiting for tab switcher to be %@.",
+ activeStatusString];
+ BOOL (^activeTabSwitcherBlock)
+ () = ^BOOL {
+ BOOL isActive = chrome_test_util::GetStackViewController() &&
+ chrome_test_util::IsTabSwitcherActive();
+ return active ? isActive : !isActive;
+ };
+ GREYCondition* activeTabSwitcherCondition =
+ [GREYCondition conditionWithName:activeTabSwitcherDescription
+ block:activeTabSwitcherBlock];
+ NSString* assertDescription = [NSString
+ stringWithFormat:@"Tab switcher did not become %@.", activeStatusString];
+
+ GREYAssert([activeTabSwitcherCondition
+ waitWithTimeout:testing::kWaitForUIElementTimeout],
+ assertDescription);
+}
+
+// Verify the visibility of the stack view.
void CheckForStackViewVisibility(bool visible) {
id<GREYMatcher> visibilityMatcher =
grey_allOf(visible ? grey_sufficientlyVisible() : grey_notVisible(),
@@ -70,6 +94,7 @@ void OpenStackView() {
[[EarlGrey selectElementWithMatcher:stackButtonMatcher]
performAction:grey_tap()];
// Verify that a StackViewController was presented.
+ WaitForStackViewActive(true);
CheckForStackViewVisibility(true);
}
@@ -105,6 +130,7 @@ void OpenNewTabUsingStackView() {
ShowDeckWithType(DeckType::NORMAL);
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"New Tab")]
performAction:grey_tap()];
+ WaitForStackViewActive(false);
CheckForStackViewVisibility(false);
}
@@ -121,6 +147,7 @@ void OpenNewIncognitoTabUsingStackView() {
NSString* newIncognitoTabID = kToolsMenuNewIncognitoTabId;
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(newIncognitoTabID)]
performAction:grey_tap()];
+ WaitForStackViewActive(false);
CheckForStackViewVisibility(false);
}
@@ -137,6 +164,7 @@ void SelectTabUsingStackView(Tab* tab) {
[[EarlGrey selectElementWithMatcher:ViewMatchingView(card_title_label)]
performAction:grey_tap()];
// Wait for the StackViewController to be dismissed.
+ WaitForStackViewActive(false);
CheckForStackViewVisibility(false);
// Checks that the next Tab has been selected.
GREYAssertEqual(tab, chrome_test_util::GetCurrentTab(),
@@ -187,13 +215,7 @@ - (void)testCloseTab {
}
// Tests closing all Tabs in the stack view.
-// TODO(crbug.com/693517): Re-enable this test on simulator.
-#if TARGET_IPHONE_SIMULATOR
-#define MAYBE_testCloseAllTabs FLAKY_testCloseAllTabs
-#else
-#define MAYBE_testCloseAllTabs testCloseAllTabs
-#endif
-- (void)MAYBE_testCloseAllTabs {
+- (void)testCloseAllTabs {
// The StackViewController is only used on iPhones.
if (IsIPadIdiom())
EARL_GREY_TEST_SKIPPED(@"Stack view is not used on iPads.");
« no previous file with comments | « ios/chrome/browser/ui/stack_view/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698