OLD | NEW |
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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 return false; | 114 return false; |
115 } | 115 } |
116 | 116 |
117 // Parses the JSON data attached to the |message| and tries to return it. | 117 // Parses the JSON data attached to the |message| and tries to return it. |
118 // |param| must outlive |out|. Returns NULL on failure. | 118 // |param| must outlive |out|. Returns NULL on failure. |
119 void GetPartOfMessageArguments(IPC::Message* message, | 119 void GetPartOfMessageArguments(IPC::Message* message, |
120 const base::DictionaryValue** out, | 120 const base::DictionaryValue** out, |
121 ExtensionMsg_MessageInvoke::Param* param) { | 121 ExtensionMsg_MessageInvoke::Param* param) { |
122 ASSERT_EQ(ExtensionMsg_MessageInvoke::ID, message->type()); | 122 ASSERT_EQ(ExtensionMsg_MessageInvoke::ID, message->type()); |
123 ASSERT_TRUE(ExtensionMsg_MessageInvoke::Read(message, param)); | 123 ASSERT_TRUE(ExtensionMsg_MessageInvoke::Read(message, param)); |
124 ASSERT_GE(get<3>(*param).GetSize(), 2u); | 124 ASSERT_GE(base::get<3>(*param).GetSize(), 2u); |
125 const base::Value* value = NULL; | 125 const base::Value* value = NULL; |
126 ASSERT_TRUE(get<3>(*param).Get(1, &value)); | 126 ASSERT_TRUE(base::get<3>(*param).Get(1, &value)); |
127 const base::ListValue* list = NULL; | 127 const base::ListValue* list = NULL; |
128 ASSERT_TRUE(value->GetAsList(&list)); | 128 ASSERT_TRUE(value->GetAsList(&list)); |
129 ASSERT_EQ(1u, list->GetSize()); | 129 ASSERT_EQ(1u, list->GetSize()); |
130 ASSERT_TRUE(list->GetDictionary(0, out)); | 130 ASSERT_TRUE(list->GetDictionary(0, out)); |
131 } | 131 } |
132 | 132 |
133 } // namespace | 133 } // namespace |
134 | 134 |
135 // A mock event router that responds to events with a pre-arranged queue of | 135 // A mock event router that responds to events with a pre-arranged queue of |
136 // Tasks. | 136 // Tasks. |
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 | 918 |
919 // Search the onSendHeaders signal in the IPC messages and check that | 919 // Search the onSendHeaders signal in the IPC messages and check that |
920 // it contained the correct headers. | 920 // it contained the correct headers. |
921 TestIPCSender::SentMessages::const_iterator i; | 921 TestIPCSender::SentMessages::const_iterator i; |
922 for (i = ipc_sender_.sent_begin(); i != ipc_sender_.sent_end(); ++i) { | 922 for (i = ipc_sender_.sent_begin(); i != ipc_sender_.sent_end(); ++i) { |
923 IPC::Message* message = i->get(); | 923 IPC::Message* message = i->get(); |
924 if (ExtensionMsg_MessageInvoke::ID != message->type()) | 924 if (ExtensionMsg_MessageInvoke::ID != message->type()) |
925 continue; | 925 continue; |
926 ExtensionMsg_MessageInvoke::Param message_tuple; | 926 ExtensionMsg_MessageInvoke::Param message_tuple; |
927 ExtensionMsg_MessageInvoke::Read(message, &message_tuple); | 927 ExtensionMsg_MessageInvoke::Read(message, &message_tuple); |
928 base::ListValue& args = get<3>(message_tuple); | 928 base::ListValue& args = base::get<3>(message_tuple); |
929 | 929 |
930 std::string event_name; | 930 std::string event_name; |
931 if (!args.GetString(0, &event_name) || | 931 if (!args.GetString(0, &event_name) || |
932 event_name != std::string(keys::kOnSendHeadersEvent) + "/3") { | 932 event_name != std::string(keys::kOnSendHeadersEvent) + "/3") { |
933 continue; | 933 continue; |
934 } | 934 } |
935 | 935 |
936 base::ListValue* event_arg = NULL; | 936 base::ListValue* event_arg = NULL; |
937 ASSERT_TRUE(args.GetList(1, &event_arg)); | 937 ASSERT_TRUE(args.GetList(1, &event_arg)); |
938 | 938 |
(...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2231 EXPECT_TRUE(credentials_set); | 2231 EXPECT_TRUE(credentials_set); |
2232 EXPECT_FALSE(auth3.Empty()); | 2232 EXPECT_FALSE(auth3.Empty()); |
2233 EXPECT_EQ(username, auth1.username()); | 2233 EXPECT_EQ(username, auth1.username()); |
2234 EXPECT_EQ(password, auth1.password()); | 2234 EXPECT_EQ(password, auth1.password()); |
2235 EXPECT_EQ(1u, warning_set.size()); | 2235 EXPECT_EQ(1u, warning_set.size()); |
2236 EXPECT_TRUE(HasWarning(warning_set, "extid2")); | 2236 EXPECT_TRUE(HasWarning(warning_set, "extid2")); |
2237 EXPECT_EQ(3u, capturing_net_log.GetSize()); | 2237 EXPECT_EQ(3u, capturing_net_log.GetSize()); |
2238 } | 2238 } |
2239 | 2239 |
2240 } // namespace extensions | 2240 } // namespace extensions |
OLD | NEW |