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

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

Issue 2608553002: [OfflinePages] Improve visiblity/handling of "Loading not started" case (Closed)
Patch Set: Addes ! low-end device default to test Setup Created 3 years, 11 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/prerendering_offliner.h" 5 #include "chrome/browser/android/offline_pages/prerendering_offliner.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 25 matching lines...) Expand all
36 class MockPrerenderingLoader : public PrerenderingLoader { 36 class MockPrerenderingLoader : public PrerenderingLoader {
37 public: 37 public:
38 explicit MockPrerenderingLoader(content::BrowserContext* browser_context) 38 explicit MockPrerenderingLoader(content::BrowserContext* browser_context)
39 : PrerenderingLoader(browser_context), 39 : PrerenderingLoader(browser_context),
40 can_prerender_(true), 40 can_prerender_(true),
41 mock_loading_(false), 41 mock_loading_(false),
42 mock_loaded_(false) {} 42 mock_loaded_(false) {}
43 ~MockPrerenderingLoader() override {} 43 ~MockPrerenderingLoader() override {}
44 44
45 bool LoadPage(const GURL& url, const LoadPageCallback& callback) override { 45 bool LoadPage(const GURL& url, const LoadPageCallback& callback) override {
46 mock_loading_ = true; 46 mock_loading_ = can_prerender_;
47 load_page_callback_ = callback; 47 load_page_callback_ = callback;
48 return mock_loading_; 48 return mock_loading_;
49 } 49 }
50 50
51 void StopLoading() override { 51 void StopLoading() override {
52 mock_loading_ = false; 52 mock_loading_ = false;
53 mock_loaded_ = false; 53 mock_loaded_ = false;
54 } 54 }
55 55
56 bool CanPrerender() override { return can_prerender_; }
57 bool IsIdle() override { return !mock_loading_ && !mock_loaded_; } 56 bool IsIdle() override { return !mock_loading_ && !mock_loaded_; }
58 bool IsLoaded() override { return mock_loaded_; } 57 bool IsLoaded() override { return mock_loaded_; }
59 58
60 void CompleteLoadingAsFailed() { 59 void CompleteLoadingAsFailed() {
61 DCHECK(mock_loading_); 60 DCHECK(mock_loading_);
62 mock_loading_ = false; 61 mock_loading_ = false;
63 mock_loaded_ = false; 62 mock_loaded_ = false;
64 base::ThreadTaskRunnerHandle::Get()->PostTask( 63 base::ThreadTaskRunnerHandle::Get()->PostTask(
65 FROM_HERE, 64 FROM_HERE,
66 base::Bind(load_page_callback_, Offliner::RequestStatus::LOADING_FAILED, 65 base::Bind(load_page_callback_, Offliner::RequestStatus::LOADING_FAILED,
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 EXPECT_FALSE(loader()->IsIdle()); 393 EXPECT_FALSE(loader()->IsIdle());
395 394
396 offliner()->SetApplicationStateForTesting( 395 offliner()->SetApplicationStateForTesting(
397 base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES); 396 base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES);
398 397
399 // Loader still loading since not low-end device. 398 // Loader still loading since not low-end device.
400 EXPECT_FALSE(loader()->IsIdle()); 399 EXPECT_FALSE(loader()->IsIdle());
401 } 400 }
402 401
403 } // namespace offline_pages 402 } // namespace offline_pages
OLDNEW
« no previous file with comments | « chrome/browser/android/offline_pages/prerendering_offliner.cc ('k') | components/offline_pages/core/background/offliner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698