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

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

Issue 2299373002: Revert of Fix WebRequest's EventListener::operator< (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 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
« no previous file with comments | « no previous file | extensions/browser/api/web_request/web_request_api.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <queue> 10 #include <queue>
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 const base::DictionaryValue* details = NULL; 826 const base::DictionaryValue* details = NULL;
827 ExtensionMsg_MessageInvoke::Param param; 827 ExtensionMsg_MessageInvoke::Param param;
828 GetPartOfMessageArguments(message, &details, &param); 828 GetPartOfMessageArguments(message, &details, &param);
829 ASSERT_TRUE(details != NULL); 829 ASSERT_TRUE(details != NULL);
830 EXPECT_FALSE(details->HasKey(keys::kRequestBodyKey)); 830 EXPECT_FALSE(details->HasKey(keys::kRequestBodyKey));
831 } 831 }
832 832
833 EXPECT_EQ(i, ipc_sender_.sent_end()); 833 EXPECT_EQ(i, ipc_sender_.sent_end());
834 } 834 }
835 835
836 // Tests the sanity of operator< (crbug.com/589735).
837 TEST_F(ExtensionWebRequestTest, AddAndRemoveListeners) {
838 std::string ext_id("abcdefghijklmnopabcdefghijklmnop");
839 ExtensionWebRequestEventRouter::RequestFilter filter;
840 const std::string kEventName(web_request::OnBeforeRequest::kEventName);
841 const std::string kSubEventName = kEventName + "/1";
842 base::WeakPtrFactory<TestIPCSender> ipc_sender_factory(&ipc_sender_);
843
844 // Add two non-webview listeners.
845 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener(
846 &profile_, ext_id, ext_id, events::FOR_TEST, kEventName, kSubEventName,
847 filter, 0, 1 /* embedder_process_id */, 0,
848 ipc_sender_factory.GetWeakPtr());
849 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener(
850 &profile_, ext_id, ext_id, events::FOR_TEST, kEventName, kSubEventName,
851 filter, 0, 2 /* embedder_process_id */, 0,
852 ipc_sender_factory.GetWeakPtr());
853
854 // Now remove the events without passing an explicit process ID.
855 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener(
856 &profile_, ext_id, kSubEventName, 0 /* embedder_process_id */, 0);
857 EXPECT_EQ(1,
858 ExtensionWebRequestEventRouter::GetInstance()->GetListenerCountForTesting(
859 &profile_, kEventName));
860
861 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener(
862 &profile_, ext_id, kSubEventName, 0 /* embedder_process_id */, 0);
863 EXPECT_EQ(0,
864 ExtensionWebRequestEventRouter::GetInstance()->GetListenerCountForTesting(
865 &profile_, kEventName));
866 }
867
868 struct HeaderModificationTest_Header { 836 struct HeaderModificationTest_Header {
869 const char* name; 837 const char* name;
870 const char* value; 838 const char* value;
871 }; 839 };
872 840
873 struct HeaderModificationTest_Modification { 841 struct HeaderModificationTest_Modification {
874 enum Type { 842 enum Type {
875 SET, 843 SET,
876 REMOVE 844 REMOVE
877 }; 845 };
(...skipping 1468 matching lines...) Expand 10 before | Expand all | Expand 10 after
2346 EXPECT_TRUE(credentials_set); 2314 EXPECT_TRUE(credentials_set);
2347 EXPECT_FALSE(auth3.Empty()); 2315 EXPECT_FALSE(auth3.Empty());
2348 EXPECT_EQ(username, auth1.username()); 2316 EXPECT_EQ(username, auth1.username());
2349 EXPECT_EQ(password, auth1.password()); 2317 EXPECT_EQ(password, auth1.password());
2350 EXPECT_EQ(1u, warning_set.size()); 2318 EXPECT_EQ(1u, warning_set.size());
2351 EXPECT_TRUE(HasWarning(warning_set, "extid2")); 2319 EXPECT_TRUE(HasWarning(warning_set, "extid2"));
2352 EXPECT_EQ(3u, capturing_net_log.GetSize()); 2320 EXPECT_EQ(3u, capturing_net_log.GetSize());
2353 } 2321 }
2354 2322
2355 } // namespace extensions 2323 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | extensions/browser/api/web_request/web_request_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698