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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/history/StubbedHistoryProvider.java

Issue 2603403003: [Android History] Add tests for removing items (Closed)
Patch Set: Changes from dfalcantara@ review Created 3 years, 11 months 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 | « chrome/android/javatests/src/org/chromium/chrome/browser/history/OWNERS ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/javatests/src/org/chromium/chrome/browser/history/StubbedHistoryProvider.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/history/StubbedHistoryProvider.java b/chrome/android/javatests/src/org/chromium/chrome/browser/history/StubbedHistoryProvider.java
new file mode 100644
index 0000000000000000000000000000000000000000..84091e7f9f787ada2fef841a4cfe633314b87d55
--- /dev/null
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/history/StubbedHistoryProvider.java
@@ -0,0 +1,65 @@
+// Copyright 2017 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.
+
+package org.chromium.chrome.browser.history;
+
+import org.chromium.base.test.util.CallbackHelper;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Stubs out the backends used by the native Android browsing history manager.
+ */
+public class StubbedHistoryProvider implements HistoryProvider {
+ public final CallbackHelper markItemForRemovalCallback = new CallbackHelper();
+ public final CallbackHelper removeItemsCallback = new CallbackHelper();
+
+ private BrowsingHistoryObserver mObserver;
+ private List<HistoryItem> mItems = new ArrayList<>();
+ private List<HistoryItem> mRemovedItems = new ArrayList<>();
+
+ @Override
+ public void setObserver(BrowsingHistoryObserver observer) {
+ mObserver = observer;
+ }
+
+ @Override
+ public void queryHistory(String query, long endQueryTime) {
+ mObserver.onQueryHistoryComplete(mItems, false);
+ }
+
+ @Override
+ public void markItemForRemoval(HistoryItem item) {
+ mRemovedItems.add(item);
+ markItemForRemovalCallback.notifyCalled();
+ }
+
+ @Override
+ public void removeItems() {
+ for (HistoryItem item : mRemovedItems) {
+ mItems.remove(item);
+ }
+ mRemovedItems.clear();
+ removeItemsCallback.notifyCalled();
+ }
+
+ @Override
+ public void destroy() {}
+
+ public void addItem(HistoryItem item) {
+ mItems.add(item);
+ }
+
+ public static HistoryItem createHistoryItem(int which, long[] timestamps) {
+ if (which == 0) {
+ return new HistoryItem("http://google.com/", "www.google.com", "Google", timestamps);
+ } else if (which == 1) {
+ return new HistoryItem("http://foo.com/", "www.foo.com", "Foo", timestamps);
+ } else {
+ return null;
+ }
+ }
+
+}
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/history/OWNERS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698