| OLD | NEW | 
|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_utils.h" | 5 #include "chrome/browser/android/offline_pages/offline_page_utils.h" | 
| 6 | 6 | 
| 7 #include <stdint.h> | 7 #include <stdint.h> | 
| 8 #include <utility> | 8 #include <utility> | 
| 9 | 9 | 
| 10 #include "base/callback.h" | 10 #include "base/callback.h" | 
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" | 
|  | 12 #include "base/feature_list.h" | 
| 12 #include "base/files/file.h" | 13 #include "base/files/file.h" | 
| 13 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" | 
| 14 #include "base/files/file_util.h" | 15 #include "base/files/file_util.h" | 
| 15 #include "base/test/test_simple_task_runner.h" | 16 #include "base/test/test_simple_task_runner.h" | 
| 16 #include "base/thread_task_runner_handle.h" | 17 #include "base/thread_task_runner_handle.h" | 
| 17 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" | 18 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" | 
| 18 #include "chrome/browser/android/offline_pages/test_offline_page_model_builder.h
     " | 19 #include "chrome/browser/android/offline_pages/test_offline_page_model_builder.h
     " | 
| 19 #include "chrome/common/chrome_constants.h" | 20 #include "chrome/common/chrome_constants.h" | 
| 20 #include "chrome/test/base/testing_profile.h" | 21 #include "chrome/test/base/testing_profile.h" | 
|  | 22 #include "components/offline_pages/offline_page_feature.h" | 
| 21 #include "components/offline_pages/offline_page_model.h" | 23 #include "components/offline_pages/offline_page_model.h" | 
| 22 #include "components/offline_pages/offline_page_switches.h" |  | 
| 23 #include "components/offline_pages/offline_page_test_archiver.h" | 24 #include "components/offline_pages/offline_page_test_archiver.h" | 
| 24 #include "components/offline_pages/offline_page_test_store.h" | 25 #include "components/offline_pages/offline_page_test_store.h" | 
| 25 #include "components/offline_pages/proto/offline_pages.pb.h" | 26 #include "components/offline_pages/proto/offline_pages.pb.h" | 
| 26 #include "net/base/filename_util.h" | 27 #include "net/base/filename_util.h" | 
| 27 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" | 
| 28 #include "url/gurl.h" | 29 #include "url/gurl.h" | 
| 29 | 30 | 
| 30 namespace offline_pages { | 31 namespace offline_pages { | 
| 31 namespace { | 32 namespace { | 
| 32 | 33 | 
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 90 | 91 | 
| 91 OfflinePageUtilsTest::OfflinePageUtilsTest() | 92 OfflinePageUtilsTest::OfflinePageUtilsTest() | 
| 92     : task_runner_(new base::TestSimpleTaskRunner), | 93     : task_runner_(new base::TestSimpleTaskRunner), | 
| 93       task_runner_handle_(task_runner_) {} | 94       task_runner_handle_(task_runner_) {} | 
| 94 | 95 | 
| 95 OfflinePageUtilsTest::~OfflinePageUtilsTest() {} | 96 OfflinePageUtilsTest::~OfflinePageUtilsTest() {} | 
| 96 | 97 | 
| 97 void OfflinePageUtilsTest::SetUp() { | 98 void OfflinePageUtilsTest::SetUp() { | 
| 98   // Enables offline pages feature. | 99   // Enables offline pages feature. | 
| 99   // TODO(jianli): Remove this once the feature is completely enabled. | 100   // TODO(jianli): Remove this once the feature is completely enabled. | 
| 100   base::CommandLine::ForCurrentProcess()->AppendSwitch( | 101   base::FeatureList::ClearInstanceForTesting(); | 
| 101       switches::kEnableOfflinePages); | 102   scoped_ptr<base::FeatureList> feature_list(new base::FeatureList); | 
|  | 103   feature_list->InitializeFromCommandLine( | 
|  | 104       offline_pages::kOfflineBookmarksFeature.name, ""); | 
|  | 105   base::FeatureList::SetInstance(std::move(feature_list)); | 
| 102 | 106 | 
| 103   // Set up the factory for testing. | 107   // Set up the factory for testing. | 
| 104   OfflinePageModelFactory::GetInstance()->SetTestingFactoryAndUse( | 108   OfflinePageModelFactory::GetInstance()->SetTestingFactoryAndUse( | 
| 105       &profile_, BuildTestOfflinePageModel); | 109       &profile_, BuildTestOfflinePageModel); | 
| 106   RunUntilIdle(); | 110   RunUntilIdle(); | 
| 107 | 111 | 
| 108   // Make sure the store contains the right offline pages before the load | 112   // Make sure the store contains the right offline pages before the load | 
| 109   // happens. | 113   // happens. | 
| 110   CreateOfflinePages(); | 114   CreateOfflinePages(); | 
| 111 } | 115 } | 
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 224 TEST_F(OfflinePageUtilsTest, HasOfflinePageForOnlineURL) { | 228 TEST_F(OfflinePageUtilsTest, HasOfflinePageForOnlineURL) { | 
| 225   EXPECT_TRUE( | 229   EXPECT_TRUE( | 
| 226       OfflinePageUtils::HasOfflinePageForOnlineURL(profile(), kTestPage1Url)); | 230       OfflinePageUtils::HasOfflinePageForOnlineURL(profile(), kTestPage1Url)); | 
| 227   EXPECT_TRUE( | 231   EXPECT_TRUE( | 
| 228       OfflinePageUtils::HasOfflinePageForOnlineURL(profile(), kTestPage2Url)); | 232       OfflinePageUtils::HasOfflinePageForOnlineURL(profile(), kTestPage2Url)); | 
| 229   EXPECT_FALSE( | 233   EXPECT_FALSE( | 
| 230       OfflinePageUtils::HasOfflinePageForOnlineURL(profile(), kTestPage3Url)); | 234       OfflinePageUtils::HasOfflinePageForOnlineURL(profile(), kTestPage3Url)); | 
| 231 } | 235 } | 
| 232 | 236 | 
| 233 }  // namespace offline_pages | 237 }  // namespace offline_pages | 
| OLD | NEW | 
|---|