Commit 8e9df8dc authored by Eugene But's avatar Eugene But Committed by Commit Bot

[ios] Improve -[ChromeEarlGrey getNavigationBackListEntryCount]

- Remove "get" prefix us unnecessary, because method returns value
  directly
- Return error from ChromeEarlGreyAppInterface and assert that error is
  nil inside ChromeEarlGrey. This way the test will fail and print the
  error onstead of relying on caller to do the right thing.

Bug: None
Change-Id: I1d52347ae48b998b29e6a59d037f3adbbf5025b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2521840Reviewed-by: default avatarGuillaume Jenkins <gujen@google.com>
Commit-Queue: Eugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825386}
parent a5333c93
......@@ -352,7 +352,7 @@ using chrome_test_util::SettingsDoneButton;
@"Dummy source failed to record.");
[ChromeEarlGrey clearBrowsingHistory];
GREYAssertEqual([ChromeEarlGrey getBrowsingHistoryEntryCount], 0,
GREYAssertEqual([ChromeEarlGrey browsingHistoryEntryCount], 0,
@"History was unexpectedly non-empty");
// Other sources may have already been recorded since the data was cleared,
......
......@@ -244,7 +244,7 @@ void VerifyManagedSettingItem(NSString* accessibilityID,
// Set history to a clean state and verify it is clean.
[ChromeEarlGrey clearBrowsingHistory];
[ChromeEarlGrey resetBrowsingDataPrefs];
GREYAssertEqual([ChromeEarlGrey getBrowsingHistoryEntryCount], 0,
GREYAssertEqual([ChromeEarlGrey browsingHistoryEntryCount], 0,
@"History was unexpectedly non-empty");
// Verify that the unmanaged pref's default value is false. While we generally
......@@ -265,7 +265,7 @@ void VerifyManagedSettingItem(NSString* accessibilityID,
// Perform a navigation and make sure the history isn't changed.
[ChromeEarlGrey loadURL:testURL];
[ChromeEarlGrey waitForWebStateContainingText:pageText];
GREYAssertEqual([ChromeEarlGrey getBrowsingHistoryEntryCount], 0,
GREYAssertEqual([ChromeEarlGrey browsingHistoryEntryCount], 0,
@"History was unexpectedly non-empty");
// Force the preference to false via policy (enables history).
......@@ -277,7 +277,7 @@ void VerifyManagedSettingItem(NSString* accessibilityID,
// Perform a navigation and make sure history is being saved.
[ChromeEarlGrey loadURL:testURL];
[ChromeEarlGrey waitForWebStateContainingText:pageText];
GREYAssertEqual([ChromeEarlGrey getBrowsingHistoryEntryCount], 1,
GREYAssertEqual([ChromeEarlGrey browsingHistoryEntryCount], 1,
@"History had an unexpected entry count");
}
......
......@@ -72,8 +72,9 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error);
// cleared within a timeout.
- (void)clearBrowsingHistory;
// Gets the number of entries in the browsing history database.
- (NSInteger)getBrowsingHistoryEntryCount;
// Gets the number of entries in the browsing history database. GREYAssert is
// induced on error.
- (NSInteger)browsingHistoryEntryCount;
// Clears browsing cache. Raises an EarlGrey exception if history is not
// cleared within a timeout.
......
......@@ -125,8 +125,12 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeEarlGreyAppInterface)
GREYWaitForAppToIdle(@"App failed to idle");
}
- (NSInteger)getBrowsingHistoryEntryCount {
return [ChromeEarlGreyAppInterface getBrowsingHistoryEntryCount];
- (NSInteger)browsingHistoryEntryCount {
NSError* error = nil;
NSInteger result =
[ChromeEarlGreyAppInterface browsingHistoryEntryCountWithError:&error];
EG_TEST_HELPER_ASSERT_NO_ERROR(error);
return result;
}
- (void)removeBrowsingCache {
......
......@@ -27,7 +27,8 @@
// Returns the number of entries in the history database. Returns -1 if there
// was an error.
+ (NSInteger)getBrowsingHistoryEntryCount;
+ (NSInteger)browsingHistoryEntryCountWithError:
(NSError* __autoreleasing*)error;
// Clears browsing cache. Returns nil on success, or else an NSError indicating
// the operation failed.
......
......@@ -100,15 +100,9 @@ NSString* SerializedPref(const PrefService::Preference* pref) {
@"Clearing browser history timed out");
}
+ (NSInteger)getBrowsingHistoryEntryCount {
NSError* error = nil;
NSInteger count = chrome_test_util::GetBrowsingHistoryEntryCount(&error);
if (error != nil) {
return -1;
}
return count;
+ (NSInteger)browsingHistoryEntryCountWithError:
(NSError* __autoreleasing*)error {
return chrome_test_util::GetBrowsingHistoryEntryCount(error);
}
+ (NSError*)removeBrowsingCache {
......
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