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

Side by Side Diff: chrome/browser/android/offline_pages/offline_page_tab_helper_unittest.cc

Issue 2260443003: [Offline Pages] Clean up some constant value types for proposed_offline_id arg. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge Created 4 years, 3 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
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 #include "chrome/browser/android/offline_pages/offline_page_tab_helper.h" 5 #include "chrome/browser/android/offline_pages/offline_page_tab_helper.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/feature_list.h" 10 #include "base/feature_list.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 OfflinePageModelFactory::GetInstance()->SetTestingFactoryAndUse( 168 OfflinePageModelFactory::GetInstance()->SetTestingFactoryAndUse(
169 browser_context(), BuildTestOfflinePageModel); 169 browser_context(), BuildTestOfflinePageModel);
170 RunUntilIdle(); 170 RunUntilIdle();
171 171
172 // Saves an offline page. 172 // Saves an offline page.
173 OfflinePageModel* model = 173 OfflinePageModel* model =
174 OfflinePageModelFactory::GetForBrowserContext(browser_context()); 174 OfflinePageModelFactory::GetForBrowserContext(browser_context());
175 std::unique_ptr<OfflinePageTestArchiver> archiver(BuildArchiver( 175 std::unique_ptr<OfflinePageTestArchiver> archiver(BuildArchiver(
176 kTestPageUrl, base::FilePath(FILE_PATH_LITERAL("page1.mhtml")))); 176 kTestPageUrl, base::FilePath(FILE_PATH_LITERAL("page1.mhtml"))));
177 model->SavePage( 177 model->SavePage(
178 kTestPageUrl, kTestClientId, 0ul, std::move(archiver), 178 kTestPageUrl, kTestClientId, 0l, std::move(archiver),
179 base::Bind(&OfflinePageTabHelperTest::OnSavePageDone, AsWeakPtr())); 179 base::Bind(&OfflinePageTabHelperTest::OnSavePageDone, AsWeakPtr()));
180 RunUntilIdle(); 180 RunUntilIdle();
181 } 181 }
182 182
183 void OfflinePageTabHelperTest::TearDown() { 183 void OfflinePageTabHelperTest::TearDown() {
184 content::RenderViewHostTestHarness::TearDown(); 184 content::RenderViewHostTestHarness::TearDown();
185 } 185 }
186 186
187 void OfflinePageTabHelperTest::RunUntilIdle() { 187 void OfflinePageTabHelperTest::RunUntilIdle() {
188 base::RunLoop().RunUntilIdle(); 188 base::RunLoop().RunUntilIdle();
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 TEST_F(OfflinePageTabHelperTest, SelectBestPageForCurrentTab) { 339 TEST_F(OfflinePageTabHelperTest, SelectBestPageForCurrentTab) {
340 // Saves an offline page. 340 // Saves an offline page.
341 OfflinePageModel* model = 341 OfflinePageModel* model =
342 OfflinePageModelFactory::GetForBrowserContext(browser_context()); 342 OfflinePageModelFactory::GetForBrowserContext(browser_context());
343 std::unique_ptr<OfflinePageTestArchiver> archiver(BuildArchiver( 343 std::unique_ptr<OfflinePageTestArchiver> archiver(BuildArchiver(
344 kTestPageUrl, base::FilePath(FILE_PATH_LITERAL("page2.mhtml")))); 344 kTestPageUrl, base::FilePath(FILE_PATH_LITERAL("page2.mhtml"))));
345 345
346 // We expect this copy to be used later. 346 // We expect this copy to be used later.
347 ClientId client_id(kLastNNamespace, base::IntToString(kTabId)); 347 ClientId client_id(kLastNNamespace, base::IntToString(kTabId));
348 model->SavePage( 348 model->SavePage(
349 kTestPageUrl, client_id, 0ul, std::move(archiver), 349 kTestPageUrl, client_id, 0l, std::move(archiver),
350 base::Bind(&OfflinePageTabHelperTest::OnSavePageDone, AsWeakPtr())); 350 base::Bind(&OfflinePageTabHelperTest::OnSavePageDone, AsWeakPtr()));
351 RunUntilIdle(); 351 RunUntilIdle();
352 const int64_t expected_offline_id = offline_id(); 352 const int64_t expected_offline_id = offline_id();
353 const GURL expected_offline_url = offline_url(); 353 const GURL expected_offline_url = offline_url();
354 354
355 archiver = BuildArchiver(kTestPageUrl, 355 archiver = BuildArchiver(kTestPageUrl,
356 base::FilePath(FILE_PATH_LITERAL("page3.html"))); 356 base::FilePath(FILE_PATH_LITERAL("page3.html")));
357 client_id.id = "39"; 357 client_id.id = "39";
358 model->SavePage( 358 model->SavePage(
359 kTestPageUrl, client_id, 0ul, std::move(archiver), 359 kTestPageUrl, client_id, 0l, std::move(archiver),
360 base::Bind(&OfflinePageTabHelperTest::OnSavePageDone, AsWeakPtr())); 360 base::Bind(&OfflinePageTabHelperTest::OnSavePageDone, AsWeakPtr()));
361 RunUntilIdle(); 361 RunUntilIdle();
362 362
363 SimulateHasNetworkConnectivity(false); 363 SimulateHasNetworkConnectivity(false);
364 StartLoad(kTestPageUrl); 364 StartLoad(kTestPageUrl);
365 // Gives a chance to run delayed task to do redirection. 365 // Gives a chance to run delayed task to do redirection.
366 RunUntilIdle(); 366 RunUntilIdle();
367 367
368 const OfflinePageItem* item = 368 const OfflinePageItem* item =
369 OfflinePageUtils::GetOfflinePageFromWebContents(web_contents()); 369 OfflinePageUtils::GetOfflinePageFromWebContents(web_contents());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 // Saves an offline page. 424 // Saves an offline page.
425 OfflinePageModel* model = 425 OfflinePageModel* model =
426 OfflinePageModelFactory::GetForBrowserContext(browser_context()); 426 OfflinePageModelFactory::GetForBrowserContext(browser_context());
427 std::unique_ptr<OfflinePageTestArchiver> archiver(BuildArchiver( 427 std::unique_ptr<OfflinePageTestArchiver> archiver(BuildArchiver(
428 kTestPageUrl, 428 kTestPageUrl,
429 base::FilePath(FILE_PATH_LITERAL("AsyncLoadedPage.mhtml")))); 429 base::FilePath(FILE_PATH_LITERAL("AsyncLoadedPage.mhtml"))));
430 430
431 // We expect this Async Loading Namespace copy to be used. 431 // We expect this Async Loading Namespace copy to be used.
432 ClientId client_id(kAsyncNamespace, base::IntToString(kTabId)); 432 ClientId client_id(kAsyncNamespace, base::IntToString(kTabId));
433 model->SavePage( 433 model->SavePage(
434 kTestPageUrl, client_id, 0ul, std::move(archiver), 434 kTestPageUrl, client_id, 0l, std::move(archiver),
435 base::Bind(&OfflinePageTabHelperTest::OnSavePageDone, AsWeakPtr())); 435 base::Bind(&OfflinePageTabHelperTest::OnSavePageDone, AsWeakPtr()));
436 RunUntilIdle(); 436 RunUntilIdle();
437 const int64_t expected_offline_id = offline_id(); 437 const int64_t expected_offline_id = offline_id();
438 const GURL expected_offline_url = offline_url(); 438 const GURL expected_offline_url = offline_url();
439 439
440 SimulateHasNetworkConnectivity(false); 440 SimulateHasNetworkConnectivity(false);
441 StartLoad(kTestPageUrl); 441 StartLoad(kTestPageUrl);
442 // Gives a chance to run delayed task to do redirection. 442 // Gives a chance to run delayed task to do redirection.
443 RunUntilIdle(); 443 RunUntilIdle();
444 444
445 const OfflinePageItem* item = 445 const OfflinePageItem* item =
446 OfflinePageUtils::GetOfflinePageFromWebContents(web_contents()); 446 OfflinePageUtils::GetOfflinePageFromWebContents(web_contents());
447 EXPECT_EQ(expected_offline_id, item->offline_id); 447 EXPECT_EQ(expected_offline_id, item->offline_id);
448 EXPECT_EQ(expected_offline_url, item->GetOfflineURL()); 448 EXPECT_EQ(expected_offline_url, item->GetOfflineURL());
449 EXPECT_EQ(kAsyncNamespace, item->client_id.name_space); 449 EXPECT_EQ(kAsyncNamespace, item->client_id.name_space);
450 EXPECT_FALSE(offline_page_tab_helper()->is_offline_preview()); 450 EXPECT_FALSE(offline_page_tab_helper()->is_offline_preview());
451 } 451 }
452 452
453 } // namespace offline_pages 453 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698