| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 void OfflinePageTabHelperTest::SetUp() { | 90 void OfflinePageTabHelperTest::SetUp() { |
| 91 // Creates a test web contents. | 91 // Creates a test web contents. |
| 92 content::RenderViewHostTestHarness::SetUp(); | 92 content::RenderViewHostTestHarness::SetUp(); |
| 93 OfflinePageTabHelper::CreateForWebContents(web_contents()); | 93 OfflinePageTabHelper::CreateForWebContents(web_contents()); |
| 94 offline_page_tab_helper_ = | 94 offline_page_tab_helper_ = |
| 95 OfflinePageTabHelper::FromWebContents(web_contents()); | 95 OfflinePageTabHelper::FromWebContents(web_contents()); |
| 96 | 96 |
| 97 // Enables offline pages feature. | 97 // Enables offline pages feature. |
| 98 // TODO(jianli): Remove this once the feature is completely enabled. |
| 98 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 99 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 99 switches::kEnableOfflinePages); | 100 switches::kEnableOfflinePages); |
| 100 | 101 |
| 101 // Sets up the factory for testing. | 102 // Sets up the factory for testing. |
| 102 OfflinePageModelFactory::GetInstance()->SetTestingFactoryAndUse( | 103 OfflinePageModelFactory::GetInstance()->SetTestingFactoryAndUse( |
| 103 browser_context(), BuildTestOfflinePageModel); | 104 browser_context(), BuildTestOfflinePageModel); |
| 104 RunUntilIdle(); | 105 RunUntilIdle(); |
| 105 | 106 |
| 106 // Saves an offline page. | 107 // Saves an offline page. |
| 107 OfflinePageModel* model = | 108 OfflinePageModel* model = |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 GURL online_url = page->url; | 187 GURL online_url = page->url; |
| 187 | 188 |
| 188 StartLoad(online_url); | 189 StartLoad(online_url); |
| 189 EXPECT_EQ(online_url, controller().GetPendingEntry()->GetURL()); | 190 EXPECT_EQ(online_url, controller().GetPendingEntry()->GetURL()); |
| 190 | 191 |
| 191 FailLoad(online_url); | 192 FailLoad(online_url); |
| 192 EXPECT_EQ(offline_url, controller().GetPendingEntry()->GetURL()); | 193 EXPECT_EQ(offline_url, controller().GetPendingEntry()->GetURL()); |
| 193 } | 194 } |
| 194 | 195 |
| 195 } // namespace offline_pages | 196 } // namespace offline_pages |
| OLD | NEW |