Commit 990ee096 authored by Jérôme Lebel's avatar Jérôme Lebel Committed by Chromium LUCI CQ

[iOS][EG] Rename callback to completion

This patch should have been part of crrev.com/c/2612844.

Bug: 1143204, 1146459
Change-Id: I494e6520794936a2f969c18b9d522836ac9365cf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2613969
Commit-Queue: Eugene But <eugenebut@chromium.org>
Auto-Submit: Jérôme Lebel <jlebel@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841178}
parent b907026f
...@@ -244,17 +244,17 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeTestCaseAppInterface) ...@@ -244,17 +244,17 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeTestCaseAppInterface)
NSUUID* uuid = [NSUUID UUID]; NSUUID* uuid = [NSUUID UUID];
// Removes all the UI elements. // Removes all the UI elements.
[ChromeTestCaseAppInterface [ChromeTestCaseAppInterface
removeInfoBarsAndPresentedStateWithCallbackUUID:uuid]; removeInfoBarsAndPresentedStateWithCompletionUUID:uuid];
ConditionBlock condition = ^{ ConditionBlock condition = ^{
return [ChromeTestCaseAppInterface isCallbackInvokedWithUUID:uuid]; return [ChromeTestCaseAppInterface isCompletionInvokedWithUUID:uuid];
}; };
NSString* errorMessage = NSString* errorMessage =
@"+[ChromeTestCaseAppInterface " @"+[ChromeTestCaseAppInterface "
@"removeInfoBarsAndPresentedStateWithCallbackUUID:] callback failed"; @"removeInfoBarsAndPresentedStateWithCompletionUUID:] completion failed";
// Waits until the UI elements are removed. // Waits until the UI elements are removed.
bool callbackInvoked = base::test::ios::WaitUntilConditionOrTimeout( bool completionInvoked = base::test::ios::WaitUntilConditionOrTimeout(
base::test::ios::kWaitForUIElementTimeout, condition); base::test::ios::kWaitForUIElementTimeout, condition);
GREYAssertTrue(callbackInvoked, errorMessage); GREYAssertTrue(completionInvoked, errorMessage);
} }
+ (void)closeAllTabs { + (void)closeAllTabs {
......
...@@ -19,14 +19,15 @@ ...@@ -19,14 +19,15 @@
+ (void)resetAuthentication; + (void)resetAuthentication;
// Removes all infobars and clears any presented state. // Removes all infobars and clears any presented state.
// See +[ChromeTestCaseAppInterface isCallbackInvokedWithUUID:] to know when // See +[ChromeTestCaseAppInterface isCompletionInvokedWithUUID:] to know when
// all views are dismissed. // all views are dismissed.
+ (void)removeInfoBarsAndPresentedStateWithCallbackUUID:(NSUUID*)callbackUUID; + (void)removeInfoBarsAndPresentedStateWithCompletionUUID:
(NSUUID*)completionUUID;
// Returns YES if the callback related to |callbackUUID| has been invoked. Once // Returns YES if the completion related to |completionUUID| has been invoked.
// this method returns YES, |callbackUUID| is dropped, and a second call will // Once this method returns YES, |completionUUID| is dropped, and a second call
// return NO. // will return NO.
+ (BOOL)isCallbackInvokedWithUUID:(NSUUID*)callbackUUID; + (BOOL)isCompletionInvokedWithUUID:(NSUUID*)completionUUID;
@end @end
......
...@@ -14,10 +14,9 @@ ...@@ -14,10 +14,9 @@
namespace { namespace {
// Stores the callback UUIDs when the callback is invoked. The UUIDs can be // Stores the completion UUIDs when the completion is invoked. The UUIDs can be
// checked with +[ChromeTestCaseAppInterface isCallbackInvokedWithUUID:]. // checked with +[ChromeTestCaseAppInterface isCompletionInvokedWithUUID:].
NSMutableSet* invokedCallbackUUID = nil; NSMutableSet* invokedCompletionUUID = nil;
} }
@implementation ChromeTestCaseAppInterface @implementation ChromeTestCaseAppInterface
...@@ -35,28 +34,29 @@ NSMutableSet* invokedCallbackUUID = nil; ...@@ -35,28 +34,29 @@ NSMutableSet* invokedCallbackUUID = nil;
chrome_test_util::ResetMockAuthentication(); chrome_test_util::ResetMockAuthentication();
} }
+ (void)removeInfoBarsAndPresentedStateWithCallbackUUID:(NSUUID*)callbackUUID { + (void)removeInfoBarsAndPresentedStateWithCompletionUUID:
(NSUUID*)completionUUID {
chrome_test_util::RemoveAllInfoBars(); chrome_test_util::RemoveAllInfoBars();
chrome_test_util::ClearPresentedState(^() { chrome_test_util::ClearPresentedState(^() {
if (callbackUUID) if (completionUUID)
[self callbackInvokedWithUUID:callbackUUID]; [self completionInvokedWithUUID:completionUUID];
}); });
} }
+ (BOOL)isCallbackInvokedWithUUID:(NSUUID*)callbackUUID { + (BOOL)isCompletionInvokedWithUUID:(NSUUID*)completionUUID {
if (![invokedCallbackUUID containsObject:callbackUUID]) if (![invokedCompletionUUID containsObject:completionUUID])
return NO; return NO;
[invokedCallbackUUID removeObject:callbackUUID]; [invokedCompletionUUID removeObject:completionUUID];
return YES; return YES;
} }
#pragma mark - Private #pragma mark - Private
+ (void)callbackInvokedWithUUID:(NSUUID*)callbackUUID { + (void)completionInvokedWithUUID:(NSUUID*)completionUUID {
if (!invokedCallbackUUID) if (!invokedCompletionUUID)
invokedCallbackUUID = [NSMutableSet set]; invokedCompletionUUID = [NSMutableSet set];
DCHECK(![invokedCallbackUUID containsObject:callbackUUID]); DCHECK(![invokedCompletionUUID containsObject:completionUUID]);
[invokedCallbackUUID addObject:callbackUUID]; [invokedCompletionUUID addObject:completionUUID];
} }
@end @end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment