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

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

Issue 2245213002: Add PageLoad.* metrics for Offline Previews (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: csharrison comments Created 4 years, 4 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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
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());
370 EXPECT_EQ(expected_offline_id, item->offline_id); 370 EXPECT_EQ(expected_offline_id, item->offline_id);
371 EXPECT_EQ(expected_offline_url, item->GetOfflineURL()); 371 EXPECT_EQ(expected_offline_url, item->GetOfflineURL());
372 EXPECT_EQ(kLastNNamespace, item->client_id.name_space); 372 EXPECT_EQ(kLastNNamespace, item->client_id.name_space);
373 EXPECT_EQ(base::IntToString(kTabId), item->client_id.id); 373 EXPECT_EQ(base::IntToString(kTabId), item->client_id.id);
374 EXPECT_FALSE(offline_page_tab_helper()->is_offline_preview());
374 } 375 }
375 376
376 TEST_F(OfflinePageTabHelperTest, PageFor2GSlow) { 377 TEST_F(OfflinePageTabHelperTest, PageFor2GSlow) {
377 SimulateHasNetworkConnectivity(true); 378 SimulateHasNetworkConnectivity(true);
378 TestingProfile* test_profile = profile(); 379 TestingProfile* test_profile = profile();
379 UINetworkQualityEstimatorService* nqe_service = 380 UINetworkQualityEstimatorService* nqe_service =
380 UINetworkQualityEstimatorServiceFactory::GetForProfile(test_profile); 381 UINetworkQualityEstimatorServiceFactory::GetForProfile(test_profile);
381 nqe_service->SetEffectiveConnectionTypeForTesting( 382 nqe_service->SetEffectiveConnectionTypeForTesting(
382 net::EFFECTIVE_CONNECTION_TYPE_SLOW_2G); 383 net::EFFECTIVE_CONNECTION_TYPE_SLOW_2G);
383 384
(...skipping 13 matching lines...) Expand all
397 398
398 StartLoad(kTestPageUrl); 399 StartLoad(kTestPageUrl);
399 // Gives a chance to run delayed task to do redirection. 400 // Gives a chance to run delayed task to do redirection.
400 RunUntilIdle(); 401 RunUntilIdle();
401 402
402 // This page should be fresh enough to cause a redirect. 403 // This page should be fresh enough to cause a redirect.
403 item = OfflinePageUtils::GetOfflinePageFromWebContents(web_contents()); 404 item = OfflinePageUtils::GetOfflinePageFromWebContents(web_contents());
404 EXPECT_EQ(offline_url(), item->GetOfflineURL()); 405 EXPECT_EQ(offline_url(), item->GetOfflineURL());
405 EXPECT_EQ(online_url(), item->url); 406 EXPECT_EQ(online_url(), item->url);
406 407
408 EXPECT_TRUE(offline_page_tab_helper()->is_offline_preview());
409
407 clock()->Advance(base::TimeDelta::FromDays(8)); 410 clock()->Advance(base::TimeDelta::FromDays(8));
408 StartLoad(kTestPageUrl); 411 StartLoad(kTestPageUrl);
409 // Gives a chance to run delayed task to do redirection. 412 // Gives a chance to run delayed task to do redirection.
410 RunUntilIdle(); 413 RunUntilIdle();
411 414
412 // This page should not be fresh enough to cause a redirect. 415 // This page should not be fresh enough to cause a redirect.
413 item = OfflinePageUtils::GetOfflinePageFromWebContents(web_contents()); 416 item = OfflinePageUtils::GetOfflinePageFromWebContents(web_contents());
414 EXPECT_EQ(nullptr, item); 417 EXPECT_EQ(nullptr, item);
418 EXPECT_FALSE(offline_page_tab_helper()->is_offline_preview());
415 } 419 }
416 420
417 // This test saves another copy of page from Async Loading namespace 421 // This test saves another copy of page from Async Loading namespace
418 // and verifies it is redirected to it (as it is more recent). 422 // and verifies it is redirected to it (as it is more recent).
419 TEST_F(OfflinePageTabHelperTest, SwitchToOfflineAsyncLoadedPageOnNoNetwork) { 423 TEST_F(OfflinePageTabHelperTest, SwitchToOfflineAsyncLoadedPageOnNoNetwork) {
420 // Saves an offline page. 424 // Saves an offline page.
421 OfflinePageModel* model = 425 OfflinePageModel* model =
422 OfflinePageModelFactory::GetForBrowserContext(browser_context()); 426 OfflinePageModelFactory::GetForBrowserContext(browser_context());
423 std::unique_ptr<OfflinePageTestArchiver> archiver(BuildArchiver( 427 std::unique_ptr<OfflinePageTestArchiver> archiver(BuildArchiver(
424 kTestPageUrl, 428 kTestPageUrl,
(...skipping 11 matching lines...) Expand all
436 SimulateHasNetworkConnectivity(false); 440 SimulateHasNetworkConnectivity(false);
437 StartLoad(kTestPageUrl); 441 StartLoad(kTestPageUrl);
438 // Gives a chance to run delayed task to do redirection. 442 // Gives a chance to run delayed task to do redirection.
439 RunUntilIdle(); 443 RunUntilIdle();
440 444
441 const OfflinePageItem* item = 445 const OfflinePageItem* item =
442 OfflinePageUtils::GetOfflinePageFromWebContents(web_contents()); 446 OfflinePageUtils::GetOfflinePageFromWebContents(web_contents());
443 EXPECT_EQ(expected_offline_id, item->offline_id); 447 EXPECT_EQ(expected_offline_id, item->offline_id);
444 EXPECT_EQ(expected_offline_url, item->GetOfflineURL()); 448 EXPECT_EQ(expected_offline_url, item->GetOfflineURL());
445 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());
446 } 451 }
447 452
448 } // namespace offline_pages 453 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698