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