OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 android.test.suitebuilder.annotation.MediumTest; | 7 import android.test.suitebuilder.annotation.MediumTest; |
8 | 8 |
9 import org.chromium.base.ThreadUtils; | 9 import org.chromium.base.ThreadUtils; |
10 import org.chromium.chrome.browser.ChromeActivity; | 10 import org.chromium.chrome.browser.ChromeActivity; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 assertEquals("Offline pages count incorrect.", 1, allPages.size()); | 84 assertEquals("Offline pages count incorrect.", 1, allPages.size()); |
85 assertEquals("Offline page item url incorrect.", TEST_PAGE, offlinePage.
getUrl()); | 85 assertEquals("Offline page item url incorrect.", TEST_PAGE, offlinePage.
getUrl()); |
86 assertEquals("Offline page item bookmark ID incorrect.", BOOKMARK_ID, | 86 assertEquals("Offline page item bookmark ID incorrect.", BOOKMARK_ID, |
87 offlinePage.getBookmarkId()); | 87 offlinePage.getBookmarkId()); |
88 assertTrue("Offline page item offline file url doesn't start properly.", | 88 assertTrue("Offline page item offline file url doesn't start properly.", |
89 offlinePage.getOfflineUrl().startsWith("file:///")); | 89 offlinePage.getOfflineUrl().startsWith("file:///")); |
90 assertTrue("Offline page item offline file doesn't have the right name."
, | 90 assertTrue("Offline page item offline file doesn't have the right name."
, |
91 offlinePage.getOfflineUrl().endsWith(".mhtml")); | 91 offlinePage.getOfflineUrl().endsWith(".mhtml")); |
92 assertTrue("Offline page item offline file doesn't have the right name."
, | 92 assertTrue("Offline page item offline file doesn't have the right name."
, |
93 offlinePage.getOfflineUrl().contains("About")); | 93 offlinePage.getOfflineUrl().contains("About")); |
94 // BUG(518758): Depending on the bot the result will be either 626 or 62
7. | 94 |
| 95 // We don't care about the exact file size of the mhtml file: |
| 96 // - exact file size is not something that the end user sees or cares ab
out |
| 97 // - exact file size can vary based on external factors (i.e. see crbug.
com/518758) |
| 98 // - verification of contents of the resulting mhtml file should be cove
red by mhtml |
| 99 // serialization tests (i.e. save_page_browsertest.cc) |
| 100 // - we want to avoid overtesting and artificially requiring specific fo
rmatting and/or |
| 101 // implementation choices in the mhtml serialization code |
| 102 // OTOH, it still seems useful to assert that the file is not empty and
that its size is in |
| 103 // the right ballpark. |
95 long size = offlinePage.getFileSize(); | 104 long size = offlinePage.getFileSize(); |
96 assertTrue("Offline page item size is incorrect: " + size, size == 626 |
| size == 627); | 105 assertTrue("Offline page item size is incorrect: " + size, 600 < size &&
size < 800); |
97 } | 106 } |
98 | 107 |
99 @MediumTest | 108 @MediumTest |
100 public void testMarkPageAccessed() throws Exception { | 109 public void testMarkPageAccessed() throws Exception { |
101 loadUrl(TEST_PAGE); | 110 loadUrl(TEST_PAGE); |
102 savePage(SavePageResult.SUCCESS, TEST_PAGE); | 111 savePage(SavePageResult.SUCCESS, TEST_PAGE); |
103 OfflinePageItem offlinePage = mOfflinePageBridge.getPageByBookmarkId(BOO
KMARK_ID); | 112 OfflinePageItem offlinePage = mOfflinePageBridge.getPageByBookmarkId(BOO
KMARK_ID); |
104 assertNotNull("Offline page should be available, but it is not.", offlin
ePage); | 113 assertNotNull("Offline page should be available, but it is not.", offlin
ePage); |
105 assertEquals("Offline page access count should be 0.", 0, offlinePage.ge
tAccessCount()); | 114 assertEquals("Offline page access count should be 0.", 0, offlinePage.ge
tAccessCount()); |
106 | 115 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 result.add(item); | 223 result.add(item); |
215 } | 224 } |
216 | 225 |
217 semaphore.release(); | 226 semaphore.release(); |
218 } | 227 } |
219 }); | 228 }); |
220 assertTrue(semaphore.tryAcquire(TIMEOUT_MS, TimeUnit.MILLISECONDS)); | 229 assertTrue(semaphore.tryAcquire(TIMEOUT_MS, TimeUnit.MILLISECONDS)); |
221 return result; | 230 return result; |
222 } | 231 } |
223 } | 232 } |
OLD | NEW |