| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ios/chrome/test/earl_grey/chrome_util.h" | |
| 6 | |
| 7 #import <EarlGrey/EarlGrey.h> | |
| 8 | |
| 9 #import "ios/chrome/browser/ui/toolbar/toolbar_controller.h" | |
| 10 #import "ios/chrome/test/app/chrome_test_util.h" | |
| 11 #import "ios/testing/wait_util.h" | |
| 12 #import "ios/web/public/test/earl_grey/web_view_matchers.h" | |
| 13 | |
| 14 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
| 15 #error "This file requires ARC support." | |
| 16 #endif | |
| 17 | |
| 18 namespace { | |
| 19 const NSTimeInterval kWaitForToolbarAnimationTimeout = 1.0; | |
| 20 } // namespace | |
| 21 | |
| 22 namespace chrome_test_util { | |
| 23 | |
| 24 void AssertToolbarNotVisible() { | |
| 25 ConditionBlock condition = ^{ | |
| 26 id<GREYMatcher> toolsMenuButton = | |
| 27 grey_allOf(grey_accessibilityID(kToolbarToolsMenuButtonIdentifier), | |
| 28 grey_sufficientlyVisible(), nil); | |
| 29 NSError* error = nil; | |
| 30 [[EarlGrey selectElementWithMatcher:toolsMenuButton] | |
| 31 assertWithMatcher:grey_notNil() | |
| 32 error:&error]; | |
| 33 return error != nil; | |
| 34 }; | |
| 35 GREYAssert(testing::WaitUntilConditionOrTimeout( | |
| 36 kWaitForToolbarAnimationTimeout, condition), | |
| 37 @"The toolbar is still visible."); | |
| 38 } | |
| 39 | |
| 40 void AssertToolbarVisible() { | |
| 41 ConditionBlock condition = ^{ | |
| 42 id<GREYMatcher> toolsMenuButton = | |
| 43 grey_allOf(grey_accessibilityID(kToolbarToolsMenuButtonIdentifier), | |
| 44 grey_sufficientlyVisible(), nil); | |
| 45 NSError* error = nil; | |
| 46 [[EarlGrey selectElementWithMatcher:toolsMenuButton] | |
| 47 assertWithMatcher:grey_notNil() | |
| 48 error:&error]; | |
| 49 return error == nil; | |
| 50 }; | |
| 51 GREYAssert(testing::WaitUntilConditionOrTimeout( | |
| 52 kWaitForToolbarAnimationTimeout, condition), | |
| 53 @"The toolbar is not visible."); | |
| 54 } | |
| 55 | |
| 56 } // namespace chrome_test_util | |
| OLD | NEW |