| 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 <memory> | 5 #include <memory> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "components/prefs/pref_registry_simple.h" | 11 #include "components/prefs/pref_registry_simple.h" |
| 12 #include "components/prefs/testing_pref_service.h" | 12 #include "components/prefs/testing_pref_service.h" |
| 13 #include "components/web_resource/resource_request_allowed_notifier.h" | 13 #include "components/web_resource/resource_request_allowed_notifier.h" |
| 14 #include "components/web_resource/web_resource_service.h" | 14 #include "components/web_resource/web_resource_service.h" |
| 15 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" |
| 15 #include "net/url_request/test_url_fetcher_factory.h" | 16 #include "net/url_request/test_url_fetcher_factory.h" |
| 16 #include "net/url_request/url_request_context_getter.h" | 17 #include "net/url_request/url_request_context_getter.h" |
| 17 #include "net/url_request/url_request_status.h" | 18 #include "net/url_request/url_request_status.h" |
| 18 #include "net/url_request/url_request_test_util.h" | 19 #include "net/url_request/url_request_test_util.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 const std::string kTestUrl = "http://www.test.com"; | 23 const std::string kTestUrl = "http://www.test.com"; |
| 23 const std::string kCacheUpdatePath = "cache_update_path"; | 24 const std::string kCacheUpdatePath = "cache_update_path"; |
| 24 std::string error_message_; | 25 std::string error_message_; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 const char* disable_network_switch, | 63 const char* disable_network_switch, |
| 63 const ParseJSONCallback& parse_json_callback) | 64 const ParseJSONCallback& parse_json_callback) |
| 64 : WebResourceService(prefs, | 65 : WebResourceService(prefs, |
| 65 web_resource_server, | 66 web_resource_server, |
| 66 application_locale, | 67 application_locale, |
| 67 last_update_time_pref_name, | 68 last_update_time_pref_name, |
| 68 start_fetch_delay_ms, | 69 start_fetch_delay_ms, |
| 69 cache_update_delay_ms, | 70 cache_update_delay_ms, |
| 70 request_context, | 71 request_context, |
| 71 disable_network_switch, | 72 disable_network_switch, |
| 72 parse_json_callback){}; | 73 parse_json_callback, |
| 74 TRAFFIC_ANNOTATION_FOR_TESTS){}; |
| 73 | 75 |
| 74 void Unpack(const base::DictionaryValue& parsed_json) override{}; | 76 void Unpack(const base::DictionaryValue& parsed_json) override{}; |
| 75 }; | 77 }; |
| 76 | 78 |
| 77 class WebResourceServiceTest : public testing::Test { | 79 class WebResourceServiceTest : public testing::Test { |
| 78 public: | 80 public: |
| 79 WebResourceServiceTest() {} | 81 WebResourceServiceTest() {} |
| 80 | 82 |
| 81 void SetUp() override { | 83 void SetUp() override { |
| 82 request_context_getter_ = new net::TestURLRequestContextGetter( | 84 request_context_getter_ = new net::TestURLRequestContextGetter( |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 TEST_F(WebResourceServiceTest, FetchScheduledOnStartFetchTest) { | 147 TEST_F(WebResourceServiceTest, FetchScheduledOnStartFetchTest) { |
| 146 resource_notifier()->NotifyState( | 148 resource_notifier()->NotifyState( |
| 147 ResourceRequestAllowedNotifier::DISALLOWED_NETWORK_DOWN); | 149 ResourceRequestAllowedNotifier::DISALLOWED_NETWORK_DOWN); |
| 148 CallStartFetch(); | 150 CallStartFetch(); |
| 149 EXPECT_FALSE(GetFetchScheduled()); | 151 EXPECT_FALSE(GetFetchScheduled()); |
| 150 resource_notifier()->NotifyState(ResourceRequestAllowedNotifier::ALLOWED); | 152 resource_notifier()->NotifyState(ResourceRequestAllowedNotifier::ALLOWED); |
| 151 EXPECT_TRUE(GetFetchScheduled()); | 153 EXPECT_TRUE(GetFetchScheduled()); |
| 152 } | 154 } |
| 153 | 155 |
| 154 } // namespace web_resource | 156 } // namespace web_resource |
| OLD | NEW |