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

Unified Diff: chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/ClientIdTest.java

Issue 1804213002: [Offline pages] Fixing client ID from bookmark generation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing Created 4 years, 9 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/java/src/org/chromium/chrome/browser/offlinepages/ClientId.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/ClientIdTest.java
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/ClientIdTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/ClientIdTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..19da9fcdd35ccf08dc775affa0c4007772dbac84
--- /dev/null
+++ b/chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/ClientIdTest.java
@@ -0,0 +1,66 @@
+// 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.
+
+package org.chromium.chrome.browser.offlinepages;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import org.chromium.base.BaseChromiumApplication;
+import org.chromium.base.test.util.Feature;
+import org.chromium.components.bookmarks.BookmarkId;
+import org.chromium.components.bookmarks.BookmarkType;
+import org.chromium.testing.local.LocalRobolectricTestRunner;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.annotation.Config;
+
+/**
+ * Unit tests for ClientId.
+ */
+@RunWith(LocalRobolectricTestRunner.class)
+@Config(manifest = Config.NONE, application = BaseChromiumApplication.class)
+public class ClientIdTest {
+
+ private static final long INVALID_BOOKMARK_ID = -1;
+ private static final long TEST_BOOKMARK_ID = 42;
+
+ private static final String TEST_NAMESPACE = "TEST_NAMESPACE";
+ private static final String TEST_ID = "TEST_ID";
+
+ /**
+ * Tests ClientId#createClientIdForBookmarkId() method in cases with valid, invalid and null
+ * bookmark ID.
+ */
+ @Test
+ @Feature({"OfflinePages"})
+ public void testCreateClientIdForBookmarkId() {
+ ClientId clientId = ClientId.createClientIdForBookmarkId(
+ new BookmarkId(TEST_BOOKMARK_ID, BookmarkType.NORMAL));
+ assertNotNull(clientId);
+ assertEquals(OfflinePageBridge.BOOKMARK_NAMESPACE, clientId.getNamespace());
+ assertEquals(Long.toString(TEST_BOOKMARK_ID), clientId.getId());
+
+ clientId = ClientId.createClientIdForBookmarkId(
+ new BookmarkId(INVALID_BOOKMARK_ID, BookmarkType.NORMAL));
+ assertNotNull(clientId);
+ assertEquals(OfflinePageBridge.BOOKMARK_NAMESPACE, clientId.getNamespace());
+ assertEquals(Long.toString(INVALID_BOOKMARK_ID), clientId.getId());
+
+ clientId = ClientId.createClientIdForBookmarkId(null);
+ assertNull(clientId);
+ }
+
+ /**
+ * Ensure that ClientId works properly.
+ */
+ @Test
+ @Feature({"OfflinePages"})
+ public void testClientIdConstructor() {
+ ClientId clientId = new ClientId(TEST_NAMESPACE, TEST_ID);
+ assertEquals(TEST_NAMESPACE, clientId.getNamespace());
+ assertEquals(TEST_ID, clientId.getId());
+ }
+}
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/offlinepages/ClientId.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698