| OLD | NEW |
| 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 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 // Mock Loader for testing the Offliner calls. | 39 // Mock Loader for testing the Offliner calls. |
| 40 class MockPrerenderingLoader : public PrerenderingLoader { | 40 class MockPrerenderingLoader : public PrerenderingLoader { |
| 41 public: | 41 public: |
| 42 explicit MockPrerenderingLoader(content::BrowserContext* browser_context) | 42 explicit MockPrerenderingLoader(content::BrowserContext* browser_context) |
| 43 : PrerenderingLoader(browser_context), | 43 : PrerenderingLoader(browser_context), |
| 44 can_prerender_(true), | 44 can_prerender_(true), |
| 45 mock_loading_(false), | 45 mock_loading_(false), |
| 46 mock_loaded_(false), | 46 mock_loaded_(false), |
| 47 mock_is_lowbar_met_(false), | 47 mock_is_lowbar_met_(false), |
| 48 start_snapshot_called_(false) {} | 48 start_snapshot_called_(false), |
| 49 web_contents_(nullptr) {} |
| 49 ~MockPrerenderingLoader() override { delete web_contents_; } | 50 ~MockPrerenderingLoader() override { delete web_contents_; } |
| 50 | 51 |
| 51 bool LoadPage(const GURL& url, | 52 bool LoadPage(const GURL& url, |
| 52 const LoadPageCallback& load_done_callback, | 53 const LoadPageCallback& load_done_callback, |
| 53 const ProgressCallback& progress_callback) override { | 54 const ProgressCallback& progress_callback) override { |
| 54 mock_loading_ = can_prerender_; | 55 mock_loading_ = can_prerender_; |
| 55 load_page_callback_ = load_done_callback; | 56 load_page_callback_ = load_done_callback; |
| 56 progress_callback_ = progress_callback; | 57 progress_callback_ = progress_callback; |
| 57 return mock_loading_; | 58 return mock_loading_; |
| 58 } | 59 } |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 PumpLoop(); | 611 PumpLoop(); |
| 611 EXPECT_EQ(Offliner::RequestStatus::SAVED, request_status()); | 612 EXPECT_EQ(Offliner::RequestStatus::SAVED, request_status()); |
| 612 | 613 |
| 613 // One extra part should be added if the flag is on. | 614 // One extra part should be added if the flag is on. |
| 614 content::MHTMLExtraParts* extra_parts = | 615 content::MHTMLExtraParts* extra_parts = |
| 615 content::MHTMLExtraParts::FromWebContents(loader()->web_contents()); | 616 content::MHTMLExtraParts::FromWebContents(loader()->web_contents()); |
| 616 EXPECT_EQ(extra_parts->size(), 1); | 617 EXPECT_EQ(extra_parts->size(), 1); |
| 617 } | 618 } |
| 618 | 619 |
| 619 } // namespace offline_pages | 620 } // namespace offline_pages |
| OLD | NEW |