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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ntp/FakeRecentlyClosedTabManager.java

Issue 2610143002: Add RecentTabsPageTest (Closed)
Patch Set: Undo the prefs changes. 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
Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/FakeRecentlyClosedTabManager.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/FakeRecentlyClosedTabManager.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/FakeRecentlyClosedTabManager.java
new file mode 100644
index 0000000000000000000000000000000000000000..1945be53d0520e4886e51d876ff60d3978978636
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/FakeRecentlyClosedTabManager.java
@@ -0,0 +1,52 @@
+// 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.ntp;
+
+import org.chromium.chrome.browser.tab.Tab;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * A fake implementation of {@link RecentlyClosedTabManager} for testing purposes.
+ */
+public class FakeRecentlyClosedTabManager implements RecentlyClosedTabManager {
+ private RecentlyClosedCallback mCallback;
+ private List<RecentlyClosedTab> mTabs = new ArrayList<>();
+
+ @Override
+ public void setRecentlyClosedCallback(RecentlyClosedCallback callback) {
+ mCallback = callback;
+ }
+
+ @Override
+ public List<RecentlyClosedTab> getRecentlyClosedTabs(int maxTabCount) {
+ List<RecentlyClosedTab> tabs = new ArrayList<>();
+ for (int i = 0; i < maxTabCount && i < mTabs.size(); i++) {
+ tabs.add(mTabs.get(i));
+ }
+ return tabs;
Bernhard Bauer 2017/01/04 11:54:16 Could you do `mTabs.subList(0, Math.min(maxTabCoun
Michael van Ouwerkerk 2017/01/05 11:02:14 Perhaps, but: "The returned List is backed by this
Bernhard Bauer 2017/01/05 17:47:37 I'm okay with the code as it is, but that does bri
Michael van Ouwerkerk 2017/01/06 11:11:11 From the subList docs: https://docs.oracle.com/jav
+ }
+
+ @Override
+ public boolean openRecentlyClosedTab(
+ Tab tab, RecentlyClosedTab recentTab, int windowOpenDisposition) {
+ return false;
+ }
+
+ @Override
+ public void openRecentlyClosedTab() {}
+
+ @Override
+ public void clearRecentlyClosedTabs() {
+ mTabs.clear();
+ if (mCallback != null) mCallback.onUpdated();
+ }
+
+ public void setRecentlyClosedTabs(List<RecentlyClosedTab> tabs) {
+ mTabs = new ArrayList<>(tabs);
+ if (mCallback != null) mCallback.onUpdated();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698