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

Side by Side Diff: chrome/browser/extensions/api/web_request/web_request_api_unittest.cc

Issue 11946028: Record event activity to the extension activity log. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rename ActivityLog::IsLoggingEnabled Created 7 years, 10 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 <map> 5 #include <map>
6 #include <queue> 6 #include <queue>
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 17 matching lines...) Expand all
28 #include "chrome/browser/extensions/api/web_request/web_request_api_helpers.h" 28 #include "chrome/browser/extensions/api/web_request/web_request_api_helpers.h"
29 #include "chrome/browser/extensions/event_router_forwarder.h" 29 #include "chrome/browser/extensions/event_router_forwarder.h"
30 #include "chrome/browser/extensions/extension_warning_set.h" 30 #include "chrome/browser/extensions/extension_warning_set.h"
31 #include "chrome/browser/net/chrome_network_delegate.h" 31 #include "chrome/browser/net/chrome_network_delegate.h"
32 #include "chrome/common/extensions/extension_messages.h" 32 #include "chrome/common/extensions/extension_messages.h"
33 #include "chrome/common/extensions/features/feature.h" 33 #include "chrome/common/extensions/features/feature.h"
34 #include "chrome/common/pref_names.h" 34 #include "chrome/common/pref_names.h"
35 #include "chrome/test/base/testing_browser_process.h" 35 #include "chrome/test/base/testing_browser_process.h"
36 #include "chrome/test/base/testing_pref_service.h" 36 #include "chrome/test/base/testing_pref_service.h"
37 #include "chrome/test/base/testing_profile.h" 37 #include "chrome/test/base/testing_profile.h"
38 #include "chrome/test/base/testing_profile_manager.h"
38 #include "content/public/test/test_browser_thread.h" 39 #include "content/public/test/test_browser_thread.h"
39 #include "net/base/auth.h" 40 #include "net/base/auth.h"
40 #include "net/base/capturing_net_log.h" 41 #include "net/base/capturing_net_log.h"
41 #include "net/base/mock_host_resolver.h" 42 #include "net/base/mock_host_resolver.h"
42 #include "net/base/net_util.h" 43 #include "net/base/net_util.h"
43 #include "net/base/upload_bytes_element_reader.h" 44 #include "net/base/upload_bytes_element_reader.h"
44 #include "net/base/upload_data_stream.h" 45 #include "net/base/upload_data_stream.h"
45 #include "net/base/upload_file_element_reader.h" 46 #include "net/base/upload_file_element_reader.h"
46 #include "net/url_request/url_request_test_util.h" 47 #include "net/url_request/url_request_test_util.h"
47 #include "testing/gtest/include/gtest/gtest-message.h" 48 #include "testing/gtest/include/gtest/gtest-message.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 166
166 std::queue<base::Closure> task_queue_; 167 std::queue<base::Closure> task_queue_;
167 SentMessages sent_messages_; 168 SentMessages sent_messages_;
168 }; 169 };
169 170
170 class ExtensionWebRequestTest : public testing::Test { 171 class ExtensionWebRequestTest : public testing::Test {
171 public: 172 public:
172 ExtensionWebRequestTest() 173 ExtensionWebRequestTest()
173 : ui_thread_(content::BrowserThread::UI, &message_loop_), 174 : ui_thread_(content::BrowserThread::UI, &message_loop_),
174 io_thread_(content::BrowserThread::IO, &message_loop_), 175 io_thread_(content::BrowserThread::IO, &message_loop_),
176 profile_manager_(TestingBrowserProcess::GetGlobal()),
175 event_router_(new EventRouterForwarder) {} 177 event_router_(new EventRouterForwarder) {}
176 178
177 protected: 179 protected:
178 virtual void SetUp() OVERRIDE { 180 virtual void SetUp() OVERRIDE {
181 ASSERT_TRUE(profile_manager_.SetUp());
179 ChromeNetworkDelegate::InitializePrefsOnUIThread( 182 ChromeNetworkDelegate::InitializePrefsOnUIThread(
180 &enable_referrers_, NULL, NULL, profile_.GetTestingPrefService()); 183 &enable_referrers_, NULL, NULL, profile_.GetTestingPrefService());
181 network_delegate_.reset( 184 network_delegate_.reset(
182 new ChromeNetworkDelegate(event_router_.get(), &enable_referrers_)); 185 new ChromeNetworkDelegate(event_router_.get(), &enable_referrers_));
183 network_delegate_->set_profile(&profile_); 186 network_delegate_->set_profile(&profile_);
184 network_delegate_->set_cookie_settings( 187 network_delegate_->set_cookie_settings(
185 CookieSettings::Factory::GetForProfile(&profile_)); 188 CookieSettings::Factory::GetForProfile(&profile_));
186 context_.reset(new net::TestURLRequestContext(true)); 189 context_.reset(new net::TestURLRequestContext(true));
187 context_->set_network_delegate(network_delegate_.get()); 190 context_->set_network_delegate(network_delegate_.get());
188 context_->Init(); 191 context_->Init();
189 } 192 }
190 193
191 // Fires a URLRequest with the specified |method|, |content_type| and three 194 // Fires a URLRequest with the specified |method|, |content_type| and three
192 // elements of upload data: bytes_1, a dummy empty file, bytes_2. 195 // elements of upload data: bytes_1, a dummy empty file, bytes_2.
193 void FireURLRequestWithData(const std::string& method, 196 void FireURLRequestWithData(const std::string& method,
194 const char* content_type, 197 const char* content_type,
195 const std::vector<char>& bytes_1, 198 const std::vector<char>& bytes_1,
196 const std::vector<char>& bytes_2); 199 const std::vector<char>& bytes_2);
197 200
198 MessageLoopForIO message_loop_; 201 MessageLoopForIO message_loop_;
199 content::TestBrowserThread ui_thread_; 202 content::TestBrowserThread ui_thread_;
200 content::TestBrowserThread io_thread_; 203 content::TestBrowserThread io_thread_;
201 TestingProfile profile_; 204 TestingProfile profile_;
205 TestingProfileManager profile_manager_;
202 net::TestDelegate delegate_; 206 net::TestDelegate delegate_;
203 BooleanPrefMember enable_referrers_; 207 BooleanPrefMember enable_referrers_;
204 TestIPCSender ipc_sender_; 208 TestIPCSender ipc_sender_;
205 scoped_refptr<EventRouterForwarder> event_router_; 209 scoped_refptr<EventRouterForwarder> event_router_;
206 scoped_refptr<ExtensionInfoMap> extension_info_map_; 210 scoped_refptr<ExtensionInfoMap> extension_info_map_;
207 scoped_ptr<ChromeNetworkDelegate> network_delegate_; 211 scoped_ptr<ChromeNetworkDelegate> network_delegate_;
208 scoped_ptr<net::TestURLRequestContext> context_; 212 scoped_ptr<net::TestURLRequestContext> context_;
209 }; 213 };
210 214
211 // Tests that we handle disagreements among extensions about responses to 215 // Tests that we handle disagreements among extensions about responses to
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 int after_size; 754 int after_size;
751 HeaderModificationTest_Header after[10]; 755 HeaderModificationTest_Header after[10];
752 }; 756 };
753 757
754 class ExtensionWebRequestHeaderModificationTest : 758 class ExtensionWebRequestHeaderModificationTest :
755 public testing::TestWithParam<HeaderModificationTest> { 759 public testing::TestWithParam<HeaderModificationTest> {
756 public: 760 public:
757 ExtensionWebRequestHeaderModificationTest() 761 ExtensionWebRequestHeaderModificationTest()
758 : ui_thread_(content::BrowserThread::UI, &message_loop_), 762 : ui_thread_(content::BrowserThread::UI, &message_loop_),
759 io_thread_(content::BrowserThread::IO, &message_loop_), 763 io_thread_(content::BrowserThread::IO, &message_loop_),
764 profile_manager_(TestingBrowserProcess::GetGlobal()),
760 event_router_(new EventRouterForwarder) {} 765 event_router_(new EventRouterForwarder) {}
761 766
762 protected: 767 protected:
763 virtual void SetUp() { 768 virtual void SetUp() {
769 ASSERT_TRUE(profile_manager_.SetUp());
764 ChromeNetworkDelegate::InitializePrefsOnUIThread( 770 ChromeNetworkDelegate::InitializePrefsOnUIThread(
765 &enable_referrers_, NULL, NULL, profile_.GetTestingPrefService()); 771 &enable_referrers_, NULL, NULL, profile_.GetTestingPrefService());
766 network_delegate_.reset( 772 network_delegate_.reset(
767 new ChromeNetworkDelegate(event_router_.get(), &enable_referrers_)); 773 new ChromeNetworkDelegate(event_router_.get(), &enable_referrers_));
768 network_delegate_->set_profile(&profile_); 774 network_delegate_->set_profile(&profile_);
769 network_delegate_->set_cookie_settings( 775 network_delegate_->set_cookie_settings(
770 CookieSettings::Factory::GetForProfile(&profile_)); 776 CookieSettings::Factory::GetForProfile(&profile_));
771 context_.reset(new net::TestURLRequestContext(true)); 777 context_.reset(new net::TestURLRequestContext(true));
772 host_resolver_.reset(new net::MockHostResolver()); 778 host_resolver_.reset(new net::MockHostResolver());
773 host_resolver_->rules()->AddSimulatedFailure("doesnotexist"); 779 host_resolver_->rules()->AddSimulatedFailure("doesnotexist");
774 context_->set_host_resolver(host_resolver_.get()); 780 context_->set_host_resolver(host_resolver_.get());
775 context_->set_network_delegate(network_delegate_.get()); 781 context_->set_network_delegate(network_delegate_.get());
776 context_->Init(); 782 context_->Init();
777 } 783 }
778 784
779 MessageLoopForIO message_loop_; 785 MessageLoopForIO message_loop_;
780 content::TestBrowserThread ui_thread_; 786 content::TestBrowserThread ui_thread_;
781 content::TestBrowserThread io_thread_; 787 content::TestBrowserThread io_thread_;
782 TestingProfile profile_; 788 TestingProfile profile_;
789 TestingProfileManager profile_manager_;
783 net::TestDelegate delegate_; 790 net::TestDelegate delegate_;
784 BooleanPrefMember enable_referrers_; 791 BooleanPrefMember enable_referrers_;
785 TestIPCSender ipc_sender_; 792 TestIPCSender ipc_sender_;
786 scoped_refptr<EventRouterForwarder> event_router_; 793 scoped_refptr<EventRouterForwarder> event_router_;
787 scoped_refptr<ExtensionInfoMap> extension_info_map_; 794 scoped_refptr<ExtensionInfoMap> extension_info_map_;
788 scoped_ptr<ChromeNetworkDelegate> network_delegate_; 795 scoped_ptr<ChromeNetworkDelegate> network_delegate_;
789 scoped_ptr<net::MockHostResolver> host_resolver_; 796 scoped_ptr<net::MockHostResolver> host_resolver_;
790 scoped_ptr<net::TestURLRequestContext> context_; 797 scoped_ptr<net::TestURLRequestContext> context_;
791 }; 798 };
792 799
(...skipping 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after
2118 EXPECT_TRUE(credentials_set); 2125 EXPECT_TRUE(credentials_set);
2119 EXPECT_FALSE(auth3.Empty()); 2126 EXPECT_FALSE(auth3.Empty());
2120 EXPECT_EQ(username, auth1.username()); 2127 EXPECT_EQ(username, auth1.username());
2121 EXPECT_EQ(password, auth1.password()); 2128 EXPECT_EQ(password, auth1.password());
2122 EXPECT_EQ(1u, warning_set.size()); 2129 EXPECT_EQ(1u, warning_set.size());
2123 EXPECT_TRUE(HasWarning(warning_set, "extid2")); 2130 EXPECT_TRUE(HasWarning(warning_set, "extid2"));
2124 EXPECT_EQ(3u, capturing_net_log.GetSize()); 2131 EXPECT_EQ(3u, capturing_net_log.GetSize());
2125 } 2132 }
2126 2133
2127 } // namespace extensions 2134 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/web_request/web_request_api.cc ('k') | chrome/browser/extensions/api_actions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698