| 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 "ios/chrome/test/earl_grey/chrome_assertions.h" | 5 #import "ios/chrome/test/earl_grey/chrome_assertions.h" |
| 6 | 6 |
| 7 #import <EarlGrey/EarlGrey.h> | 7 #import <EarlGrey/EarlGrey.h> |
| 8 | 8 |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #import "ios/chrome/test/app/tab_test_util.h" | 10 #import "ios/chrome/test/app/tab_test_util.h" |
| 11 #import "ios/testing/wait_util.h" | 11 #import "ios/testing/wait_util.h" |
| 12 | 12 |
| 13 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 14 #error "This file requires ARC support." |
| 15 #endif |
| 16 |
| 13 namespace chrome_test_util { | 17 namespace chrome_test_util { |
| 14 | 18 |
| 15 void AssertMainTabCount(NSUInteger expected_tab_count) { | 19 void AssertMainTabCount(NSUInteger expected_tab_count) { |
| 16 // Allow the UI to become idle, in case any tabs are being opened or closed. | 20 // Allow the UI to become idle, in case any tabs are being opened or closed. |
| 17 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; | 21 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; |
| 18 GREYAssert(testing::WaitUntilConditionOrTimeout( | 22 GREYAssert(testing::WaitUntilConditionOrTimeout( |
| 19 testing::kWaitForUIElementTimeout, | 23 testing::kWaitForUIElementTimeout, |
| 20 ^{ | 24 ^{ |
| 21 return GetMainTabCount() == expected_tab_count; | 25 return GetMainTabCount() == expected_tab_count; |
| 22 }), | 26 }), |
| 23 @"Did not receive %" PRIuNS " tabs", expected_tab_count); | 27 @"Did not receive %" PRIuNS " tabs", expected_tab_count); |
| 24 } | 28 } |
| 25 | 29 |
| 26 void AssertIncognitoTabCount(NSUInteger expected_tab_count) { | 30 void AssertIncognitoTabCount(NSUInteger expected_tab_count) { |
| 27 // Allow the UI to become idle, in case any tabs are being opened or closed. | 31 // Allow the UI to become idle, in case any tabs are being opened or closed. |
| 28 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; | 32 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; |
| 29 ConditionBlock condition = ^{ | 33 ConditionBlock condition = ^{ |
| 30 return GetIncognitoTabCount() == expected_tab_count; | 34 return GetIncognitoTabCount() == expected_tab_count; |
| 31 }; | 35 }; |
| 32 GREYAssert(testing::WaitUntilConditionOrTimeout( | 36 GREYAssert(testing::WaitUntilConditionOrTimeout( |
| 33 testing::kWaitForUIElementTimeout, condition), | 37 testing::kWaitForUIElementTimeout, condition), |
| 34 @"Did not receive %" PRIuNS " incognito tabs", expected_tab_count); | 38 @"Did not receive %" PRIuNS " incognito tabs", expected_tab_count); |
| 35 } | 39 } |
| 36 | 40 |
| 37 } // namespace chrome_test_util | 41 } // namespace chrome_test_util |
| OLD | NEW |