@MediumTest public void testGetPageByBookmarkId() throws Exception { loadUrl(TEST_PAGE); savePage(SavePageResult.SUCCESS, TEST_PAGE); OfflinePageItem offlinePage = mOfflinePageBridge.getPageByBookmarkId(BOOKMARK_ID); assertEquals("Offline page item url incorrect.", TEST_PAGE, offlinePage.getUrl()); assertEquals( "Offline page item bookmark ID incorrect.", BOOKMARK_ID, offlinePage.getBookmarkId()); assertTrue( "Offline page item offline file url doesn't start properly.", offlinePage.getOfflineUrl().startsWith("file:///")); assertTrue( "Offline page item offline file doesn't have the right name.", offlinePage.getOfflineUrl().endsWith(".mhtml")); assertTrue( "Offline page item offline file doesn't have the right name.", offlinePage.getOfflineUrl().contains("About")); assertNull( "Offline page is not supposed to exist", mOfflinePageBridge.getPageByBookmarkId(new BookmarkId(-42, BookmarkType.NORMAL))); }
@MediumTest public void testAddOfflinePageAndLoad() throws Exception { loadUrl(TEST_PAGE); savePage(SavePageResult.SUCCESS, TEST_PAGE); List<OfflinePageItem> allPages = getAllPages(); OfflinePageItem offlinePage = allPages.get(0); assertEquals("Offline pages count incorrect.", 1, allPages.size()); assertEquals("Offline page item url incorrect.", TEST_PAGE, offlinePage.getUrl()); assertEquals( "Offline page item bookmark ID incorrect.", BOOKMARK_ID, offlinePage.getBookmarkId()); assertTrue( "Offline page item offline file url doesn't start properly.", offlinePage.getOfflineUrl().startsWith("file:///")); assertTrue( "Offline page item offline file doesn't have the right name.", offlinePage.getOfflineUrl().endsWith(".mhtml")); assertTrue( "Offline page item offline file doesn't have the right name.", offlinePage.getOfflineUrl().contains("About")); // BUG(518758): Depending on the bot the result will be either 626 or 627. long size = offlinePage.getFileSize(); assertTrue("Offline page item size is incorrect: " + size, size == 626 || size == 627); }