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

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

Issue 2121873002: Fix WebRequest's EventListener::operator< (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix WebRequest's EventListener::operator< Created 4 years, 5 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 <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, ExtensionWebRequestEventRouter::GetInstance()->GetListenerCount(
858 &profile_, kEventName));
859
860 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener(
861 &profile_, ext_id, kSubEventName, 0 /* embedder_process_id */, 0);
862 EXPECT_EQ(0, ExtensionWebRequestEventRouter::GetInstance()->GetListenerCount(
863 &profile_, kEventName));
864 }
865
836 struct HeaderModificationTest_Header { 866 struct HeaderModificationTest_Header {
837 const char* name; 867 const char* name;
838 const char* value; 868 const char* value;
839 }; 869 };
840 870
841 struct HeaderModificationTest_Modification { 871 struct HeaderModificationTest_Modification {
842 enum Type { 872 enum Type {
843 SET, 873 SET,
844 REMOVE 874 REMOVE
845 }; 875 };
(...skipping 1468 matching lines...) Expand 10 before | Expand all | Expand 10 after
2314 EXPECT_TRUE(credentials_set); 2344 EXPECT_TRUE(credentials_set);
2315 EXPECT_FALSE(auth3.Empty()); 2345 EXPECT_FALSE(auth3.Empty());
2316 EXPECT_EQ(username, auth1.username()); 2346 EXPECT_EQ(username, auth1.username());
2317 EXPECT_EQ(password, auth1.password()); 2347 EXPECT_EQ(password, auth1.password());
2318 EXPECT_EQ(1u, warning_set.size()); 2348 EXPECT_EQ(1u, warning_set.size());
2319 EXPECT_TRUE(HasWarning(warning_set, "extid2")); 2349 EXPECT_TRUE(HasWarning(warning_set, "extid2"));
2320 EXPECT_EQ(3u, capturing_net_log.GetSize()); 2350 EXPECT_EQ(3u, capturing_net_log.GetSize());
2321 } 2351 }
2322 2352
2323 } // namespace extensions 2353 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698