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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <queue> | 9 #include <queue> |
| 10 #include <tuple> |
10 | 11 |
11 #include "base/bind.h" | 12 #include "base/bind.h" |
12 #include "base/callback.h" | 13 #include "base/callback.h" |
13 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
14 #include "base/json/json_reader.h" | 15 #include "base/json/json_reader.h" |
15 #include "base/json/json_string_value_serializer.h" | 16 #include "base/json/json_string_value_serializer.h" |
16 #include "base/location.h" | 17 #include "base/location.h" |
17 #include "base/macros.h" | 18 #include "base/macros.h" |
18 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
19 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 return false; | 121 return false; |
121 } | 122 } |
122 | 123 |
123 // Parses the JSON data attached to the |message| and tries to return it. | 124 // Parses the JSON data attached to the |message| and tries to return it. |
124 // |param| must outlive |out|. Returns NULL on failure. | 125 // |param| must outlive |out|. Returns NULL on failure. |
125 void GetPartOfMessageArguments(IPC::Message* message, | 126 void GetPartOfMessageArguments(IPC::Message* message, |
126 const base::DictionaryValue** out, | 127 const base::DictionaryValue** out, |
127 ExtensionMsg_MessageInvoke::Param* param) { | 128 ExtensionMsg_MessageInvoke::Param* param) { |
128 ASSERT_EQ(ExtensionMsg_MessageInvoke::ID, message->type()); | 129 ASSERT_EQ(ExtensionMsg_MessageInvoke::ID, message->type()); |
129 ASSERT_TRUE(ExtensionMsg_MessageInvoke::Read(message, param)); | 130 ASSERT_TRUE(ExtensionMsg_MessageInvoke::Read(message, param)); |
130 ASSERT_GE(base::get<3>(*param).GetSize(), 2u); | 131 ASSERT_GE(std::get<3>(*param).GetSize(), 2u); |
131 const base::Value* value = NULL; | 132 const base::Value* value = NULL; |
132 ASSERT_TRUE(base::get<3>(*param).Get(1, &value)); | 133 ASSERT_TRUE(std::get<3>(*param).Get(1, &value)); |
133 const base::ListValue* list = NULL; | 134 const base::ListValue* list = NULL; |
134 ASSERT_TRUE(value->GetAsList(&list)); | 135 ASSERT_TRUE(value->GetAsList(&list)); |
135 ASSERT_EQ(1u, list->GetSize()); | 136 ASSERT_EQ(1u, list->GetSize()); |
136 ASSERT_TRUE(list->GetDictionary(0, out)); | 137 ASSERT_TRUE(list->GetDictionary(0, out)); |
137 } | 138 } |
138 | 139 |
139 } // namespace | 140 } // namespace |
140 | 141 |
141 // A mock event router that responds to events with a pre-arranged queue of | 142 // A mock event router that responds to events with a pre-arranged queue of |
142 // Tasks. | 143 // Tasks. |
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 | 1001 |
1001 // Search the onSendHeaders signal in the IPC messages and check that | 1002 // Search the onSendHeaders signal in the IPC messages and check that |
1002 // it contained the correct headers. | 1003 // it contained the correct headers. |
1003 TestIPCSender::SentMessages::const_iterator i; | 1004 TestIPCSender::SentMessages::const_iterator i; |
1004 for (i = ipc_sender_.sent_begin(); i != ipc_sender_.sent_end(); ++i) { | 1005 for (i = ipc_sender_.sent_begin(); i != ipc_sender_.sent_end(); ++i) { |
1005 IPC::Message* message = i->get(); | 1006 IPC::Message* message = i->get(); |
1006 if (ExtensionMsg_MessageInvoke::ID != message->type()) | 1007 if (ExtensionMsg_MessageInvoke::ID != message->type()) |
1007 continue; | 1008 continue; |
1008 ExtensionMsg_MessageInvoke::Param message_tuple; | 1009 ExtensionMsg_MessageInvoke::Param message_tuple; |
1009 ExtensionMsg_MessageInvoke::Read(message, &message_tuple); | 1010 ExtensionMsg_MessageInvoke::Read(message, &message_tuple); |
1010 base::ListValue& args = base::get<3>(message_tuple); | 1011 base::ListValue& args = std::get<3>(message_tuple); |
1011 | 1012 |
1012 std::string event_name; | 1013 std::string event_name; |
1013 if (!args.GetString(0, &event_name) || | 1014 if (!args.GetString(0, &event_name) || |
1014 event_name != std::string(keys::kOnSendHeadersEvent) + "/3") { | 1015 event_name != std::string(keys::kOnSendHeadersEvent) + "/3") { |
1015 continue; | 1016 continue; |
1016 } | 1017 } |
1017 | 1018 |
1018 base::ListValue* event_arg = NULL; | 1019 base::ListValue* event_arg = NULL; |
1019 ASSERT_TRUE(args.GetList(1, &event_arg)); | 1020 ASSERT_TRUE(args.GetList(1, &event_arg)); |
1020 | 1021 |
(...skipping 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2314 EXPECT_TRUE(credentials_set); | 2315 EXPECT_TRUE(credentials_set); |
2315 EXPECT_FALSE(auth3.Empty()); | 2316 EXPECT_FALSE(auth3.Empty()); |
2316 EXPECT_EQ(username, auth1.username()); | 2317 EXPECT_EQ(username, auth1.username()); |
2317 EXPECT_EQ(password, auth1.password()); | 2318 EXPECT_EQ(password, auth1.password()); |
2318 EXPECT_EQ(1u, warning_set.size()); | 2319 EXPECT_EQ(1u, warning_set.size()); |
2319 EXPECT_TRUE(HasWarning(warning_set, "extid2")); | 2320 EXPECT_TRUE(HasWarning(warning_set, "extid2")); |
2320 EXPECT_EQ(3u, capturing_net_log.GetSize()); | 2321 EXPECT_EQ(3u, capturing_net_log.GetSize()); |
2321 } | 2322 } |
2322 | 2323 |
2323 } // namespace extensions | 2324 } // namespace extensions |
OLD | NEW |