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

Side by Side Diff: chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry_unittest.cc

Issue 2799883003: Switch from TestBrowserThread to TestBrowserThreadBundle in chrome. (Closed)
Patch Set: fix-string Created 3 years, 7 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "extensions/browser/api/declarative_webrequest/webrequest_rules_registr y.h" 5 #include "extensions/browser/api/declarative_webrequest/webrequest_rules_registr y.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/json/json_reader.h" 14 #include "base/json/json_reader.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/linked_ptr.h" 16 #include "base/memory/linked_ptr.h"
17 #include "base/memory/ptr_util.h" 17 #include "base/memory/ptr_util.h"
18 #include "base/message_loop/message_loop.h"
19 #include "base/run_loop.h" 18 #include "base/run_loop.h"
20 #include "base/stl_util.h" 19 #include "base/stl_util.h"
21 #include "base/test/values_test_util.h" 20 #include "base/test/values_test_util.h"
22 #include "base/values.h" 21 #include "base/values.h"
23 #include "chrome/common/extensions/extension_test_util.h" 22 #include "chrome/common/extensions/extension_test_util.h"
24 #include "components/url_matcher/url_matcher_constants.h" 23 #include "components/url_matcher/url_matcher_constants.h"
25 #include "content/public/test/test_browser_thread.h" 24 #include "content/public/test/test_browser_thread_bundle.h"
26 #include "extensions/browser/api/declarative/rules_registry_service.h" 25 #include "extensions/browser/api/declarative/rules_registry_service.h"
27 #include "extensions/browser/api/declarative_webrequest/webrequest_constants.h" 26 #include "extensions/browser/api/declarative_webrequest/webrequest_constants.h"
28 #include "extensions/browser/api/web_request/web_request_api_helpers.h" 27 #include "extensions/browser/api/web_request/web_request_api_helpers.h"
29 #include "net/base/request_priority.h" 28 #include "net/base/request_priority.h"
30 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" 29 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
31 #include "net/url_request/url_request.h" 30 #include "net/url_request/url_request.h"
32 #include "net/url_request/url_request_test_util.h" 31 #include "net/url_request/url_request_test_util.h"
33 #include "testing/gmock/include/gmock/gmock.h" 32 #include "testing/gmock/include/gmock/gmock.h"
34 #include "testing/gtest/include/gtest/gtest-message.h" 33 #include "testing/gtest/include/gtest/gtest-message.h"
35 #include "testing/gtest/include/gtest/gtest.h" 34 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 80
82 void ClearCacheOnNavigation() override { ++num_clear_cache_calls_; } 81 void ClearCacheOnNavigation() override { ++num_clear_cache_calls_; }
83 82
84 private: 83 private:
85 int num_clear_cache_calls_; 84 int num_clear_cache_calls_;
86 }; 85 };
87 86
88 class WebRequestRulesRegistryTest : public testing::Test { 87 class WebRequestRulesRegistryTest : public testing::Test {
89 public: 88 public:
90 WebRequestRulesRegistryTest() 89 WebRequestRulesRegistryTest()
91 : ui_(content::BrowserThread::UI, &message_loop_), 90 : test_browser_thread_bundle_(
92 io_(content::BrowserThread::IO, &message_loop_) {} 91 content::TestBrowserThreadBundle::IO_MAINLOOP) {}
93 92
94 ~WebRequestRulesRegistryTest() override {} 93 ~WebRequestRulesRegistryTest() override {}
95 94
96 void SetUp() override; 95 void SetUp() override;
97 96
98 void TearDown() override { 97 void TearDown() override {
99 // Make sure that deletion traits of all registries are executed. 98 // Make sure that deletion traits of all registries are executed.
100 base::RunLoop().RunUntilIdle(); 99 base::RunLoop().RunUntilIdle();
101 } 100 }
102 101
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 rule->priority.reset(new int(1)); 217 rule->priority.reset(new int(1));
219 rule->actions.push_back(action_dict.CreateDeepCopy()); 218 rule->actions.push_back(action_dict.CreateDeepCopy());
220 for (std::vector<const std::string*>::const_iterator it = 219 for (std::vector<const std::string*>::const_iterator it =
221 attributes.begin(); 220 attributes.begin();
222 it != attributes.end(); ++it) 221 it != attributes.end(); ++it)
223 rule->conditions.push_back(CreateCondition(**it)); 222 rule->conditions.push_back(CreateCondition(**it));
224 return rule; 223 return rule;
225 } 224 }
226 225
227 protected: 226 protected:
228 base::MessageLoopForIO message_loop_; 227 content::TestBrowserThreadBundle test_browser_thread_bundle_;
229 content::TestBrowserThread ui_;
230 content::TestBrowserThread io_;
231 // Two extensions with host permissions for all URLs and the DWR permission. 228 // Two extensions with host permissions for all URLs and the DWR permission.
232 // Installation times will be so that |extension_| is older than 229 // Installation times will be so that |extension_| is older than
233 // |extension2_|. 230 // |extension2_|.
234 scoped_refptr<Extension> extension_; 231 scoped_refptr<Extension> extension_;
235 scoped_refptr<Extension> extension2_; 232 scoped_refptr<Extension> extension2_;
236 scoped_refptr<InfoMap> extension_info_map_; 233 scoped_refptr<InfoMap> extension_info_map_;
237 }; 234 };
238 235
239 void WebRequestRulesRegistryTest::SetUp() { 236 void WebRequestRulesRegistryTest::SetUp() {
240 testing::Test::SetUp(); 237 testing::Test::SetUp();
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 // This is a correct match. 814 // This is a correct match.
818 GURL url2("http://foo.com/index.html"); 815 GURL url2("http://foo.com/index.html");
819 std::unique_ptr<net::URLRequest> request2(context.CreateRequest( 816 std::unique_ptr<net::URLRequest> request2(context.CreateRequest(
820 url2, net::DEFAULT_PRIORITY, NULL, TRAFFIC_ANNOTATION_FOR_TESTS)); 817 url2, net::DEFAULT_PRIORITY, NULL, TRAFFIC_ANNOTATION_FOR_TESTS));
821 WebRequestData request_data2(request2.get(), ON_BEFORE_REQUEST); 818 WebRequestData request_data2(request2.get(), ON_BEFORE_REQUEST);
822 deltas = registry->CreateDeltas(NULL, request_data2, false); 819 deltas = registry->CreateDeltas(NULL, request_data2, false);
823 EXPECT_EQ(1u, deltas.size()); 820 EXPECT_EQ(1u, deltas.size());
824 } 821 }
825 822
826 } // namespace extensions 823 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698