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

Side by Side Diff: chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/OfflinePageUtilsTest.java

Issue 1894703002: [Offline pages] Removing offline pages from Bookmarks UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Marking more methods as visible for testing Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « chrome/android/junit/src/org/chromium/chrome/browser/bookmarks/BookmarkUtilsTest.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.offlinepages; 5 package org.chromium.chrome.browser.offlinepages;
6 6
7 import static org.junit.Assert.assertEquals; 7 import static org.junit.Assert.assertEquals;
8 import static org.junit.Assert.assertFalse;
9 import static org.junit.Assert.assertTrue;
10 import static org.mockito.Mockito.when; 8 import static org.mockito.Mockito.when;
11 9
12 import android.os.Environment; 10 import android.os.Environment;
13 11
14 import org.chromium.base.BaseChromiumApplication; 12 import org.chromium.base.BaseChromiumApplication;
15 import org.chromium.base.test.shadows.ShadowMultiDex; 13 import org.chromium.base.test.shadows.ShadowMultiDex;
16 import org.chromium.base.test.util.Feature; 14 import org.chromium.base.test.util.Feature;
17 import org.chromium.testing.local.LocalRobolectricTestRunner; 15 import org.chromium.testing.local.LocalRobolectricTestRunner;
18 import org.junit.Before; 16 import org.junit.Before;
19 import org.junit.Test; 17 import org.junit.Test;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 50
53 @Test 51 @Test
54 @Feature({"OfflinePages"}) 52 @Feature({"OfflinePages"})
55 public void testGetTotalSpaceInBytes() { 53 public void testGetTotalSpaceInBytes() {
56 when(mMockDataDirectory.getTotalSpace()).thenReturn(56789L); 54 when(mMockDataDirectory.getTotalSpace()).thenReturn(56789L);
57 assertEquals(56789L, OfflinePageUtils.getTotalSpaceInBytes()); 55 assertEquals(56789L, OfflinePageUtils.getTotalSpaceInBytes());
58 } 56 }
59 57
60 @Test 58 @Test
61 @Feature({"OfflinePages"}) 59 @Feature({"OfflinePages"})
62 public void testIsStorageAlmostFull() {
63 when(mMockDataDirectory.getUsableSpace()).thenReturn(16L * (1 << 20)); // 16MB
64 assertFalse(OfflinePageUtils.isStorageAlmostFull());
65
66 when(mMockDataDirectory.getUsableSpace()).thenReturn(8L * (1 << 20)); / / 8MB
67 assertTrue(OfflinePageUtils.isStorageAlmostFull());
68 }
69
70 @Test
71 @Feature({"OfflinePages"})
72 public void testStripSchemeFromOnlineUrl() { 60 public void testStripSchemeFromOnlineUrl() {
73 // Only scheme gets stripped. 61 // Only scheme gets stripped.
74 assertEquals("cs.chromium.org", 62 assertEquals("cs.chromium.org",
75 OfflinePageUtils.stripSchemeFromOnlineUrl("https://cs.chromium.o rg")); 63 OfflinePageUtils.stripSchemeFromOnlineUrl("https://cs.chromium.o rg"));
76 assertEquals("cs.chromium.org", 64 assertEquals("cs.chromium.org",
77 OfflinePageUtils.stripSchemeFromOnlineUrl("http://cs.chromium.or g")); 65 OfflinePageUtils.stripSchemeFromOnlineUrl("http://cs.chromium.or g"));
78 // If there is no scheme, nothing changes. 66 // If there is no scheme, nothing changes.
79 assertEquals("cs.chromium.org", 67 assertEquals("cs.chromium.org",
80 OfflinePageUtils.stripSchemeFromOnlineUrl("cs.chromium.org")); 68 OfflinePageUtils.stripSchemeFromOnlineUrl("cs.chromium.org"));
81 // Path is not touched/changed. 69 // Path is not touched/changed.
(...skipping 14 matching lines...) Expand all
96 public static void setDataDirectoryForTest(File testDirectory) { 84 public static void setDataDirectoryForTest(File testDirectory) {
97 sDataDirectory = testDirectory; 85 sDataDirectory = testDirectory;
98 } 86 }
99 87
100 @Implementation 88 @Implementation
101 public static File getDataDirectory() { 89 public static File getDataDirectory() {
102 return sDataDirectory; 90 return sDataDirectory;
103 } 91 }
104 } 92 }
105 } 93 }
OLDNEW
« no previous file with comments | « chrome/android/junit/src/org/chromium/chrome/browser/bookmarks/BookmarkUtilsTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698