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

Unified Diff: ios/chrome/test/app/history_test_util.mm

Issue 2580333003: Upstream Chrome on iOS source code [10/11]. (Closed)
Patch Set: Created 4 years 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/test/app/history_test_util.h ('k') | ios/chrome/test/app/navigation_test_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/test/app/history_test_util.mm
diff --git a/ios/chrome/test/app/history_test_util.mm b/ios/chrome/test/app/history_test_util.mm
new file mode 100644
index 0000000000000000000000000000000000000000..33942f902bbe3864c4fb542cae6da460408a7079
--- /dev/null
+++ b/ios/chrome/test/app/history_test_util.mm
@@ -0,0 +1,49 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ios/chrome/test/app/history_test_util.h"
+
+#include "base/mac/bind_objc_block.h"
+#include "base/test/ios/wait_util.h"
+#include "components/browsing_data/core/browsing_data_utils.h"
+#import "ios/chrome/app/main_controller.h"
+#import "ios/chrome/app/main_controller_private.h"
+#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
+#include "ios/chrome/browser/browsing_data/ios_chrome_browsing_data_remover.h"
+#include "ios/chrome/browser/callback_counter.h"
+#import "ios/chrome/test/app/chrome_test_util.h"
+
+namespace chrome_test_util {
+
+void ClearBrowsingHistory() {
+ MainController* main_controller = GetMainController();
+ ios::ChromeBrowserState* active_state = GetOriginalBrowserState();
+ scoped_refptr<CallbackCounter> callback_counter(
+ new CallbackCounter(base::BindBlock(^{
+ })));
+ callback_counter->IncrementCount();
+ __block bool did_complete = false;
+ [main_controller
+ removeBrowsingDataFromBrowserState:active_state
+ mask:IOSChromeBrowsingDataRemover::
+ REMOVE_HISTORY
+ timePeriod:browsing_data::ALL_TIME
+ completionHandler:^{
+ callback_counter->DecrementCount();
+ did_complete = true;
+ }];
+ // TODO(crbug.com/631795): This is a workaround that will be removed soon.
+ // This code waits for success or timeout, then returns. This needs to be
+ // fixed so that failure is correctly marked here, or the caller handles
+ // waiting for the operation to complete.
+ // Wait for history to be cleared.
+ NSDate* deadline = [NSDate dateWithTimeIntervalSinceNow:4.0];
+ while (!did_complete &&
+ [[NSDate date] compare:deadline] != NSOrderedDescending) {
+ base::test::ios::SpinRunLoopWithMaxDelay(
+ base::TimeDelta::FromSecondsD(0.1));
+ }
+}
+
+} // namespace chrome_test_util
« no previous file with comments | « ios/chrome/test/app/history_test_util.h ('k') | ios/chrome/test/app/navigation_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698