| 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 DictionaryValue** out, | 119 const 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->c.GetSize(), 2u); | 123 ASSERT_GE(param->d.GetSize(), 2u); |
| 124 const Value* value = NULL; | 124 const Value* value = NULL; |
| 125 ASSERT_TRUE(param->c.Get(1, &value)); | 125 ASSERT_TRUE(param->d.Get(1, &value)); |
| 126 const ListValue* list = NULL; | 126 const 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 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 | 909 |
| 910 // Search the onSendHeaders signal in the IPC messages and check that | 910 // Search the onSendHeaders signal in the IPC messages and check that |
| 911 // it contained the correct headers. | 911 // it contained the correct headers. |
| 912 TestIPCSender::SentMessages::const_iterator i; | 912 TestIPCSender::SentMessages::const_iterator i; |
| 913 for (i = ipc_sender_.sent_begin(); i != ipc_sender_.sent_end(); ++i) { | 913 for (i = ipc_sender_.sent_begin(); i != ipc_sender_.sent_end(); ++i) { |
| 914 IPC::Message* message = i->get(); | 914 IPC::Message* message = i->get(); |
| 915 if (ExtensionMsg_MessageInvoke::ID != message->type()) | 915 if (ExtensionMsg_MessageInvoke::ID != message->type()) |
| 916 continue; | 916 continue; |
| 917 ExtensionMsg_MessageInvoke::Param message_tuple; | 917 ExtensionMsg_MessageInvoke::Param message_tuple; |
| 918 ExtensionMsg_MessageInvoke::Read(message, &message_tuple); | 918 ExtensionMsg_MessageInvoke::Read(message, &message_tuple); |
| 919 ListValue& args = message_tuple.c; | 919 ListValue& args = message_tuple.d; |
| 920 | 920 |
| 921 std::string event_name; | 921 std::string event_name; |
| 922 if (!args.GetString(0, &event_name) || | 922 if (!args.GetString(0, &event_name) || |
| 923 event_name != std::string(keys::kOnSendHeadersEvent) + "/3") { | 923 event_name != std::string(keys::kOnSendHeadersEvent) + "/3") { |
| 924 continue; | 924 continue; |
| 925 } | 925 } |
| 926 | 926 |
| 927 ListValue* event_arg = NULL; | 927 ListValue* event_arg = NULL; |
| 928 ASSERT_TRUE(args.GetList(1, &event_arg)); | 928 ASSERT_TRUE(args.GetList(1, &event_arg)); |
| 929 | 929 |
| (...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2134 EXPECT_TRUE(credentials_set); | 2134 EXPECT_TRUE(credentials_set); |
| 2135 EXPECT_FALSE(auth3.Empty()); | 2135 EXPECT_FALSE(auth3.Empty()); |
| 2136 EXPECT_EQ(username, auth1.username()); | 2136 EXPECT_EQ(username, auth1.username()); |
| 2137 EXPECT_EQ(password, auth1.password()); | 2137 EXPECT_EQ(password, auth1.password()); |
| 2138 EXPECT_EQ(1u, warning_set.size()); | 2138 EXPECT_EQ(1u, warning_set.size()); |
| 2139 EXPECT_TRUE(HasWarning(warning_set, "extid2")); | 2139 EXPECT_TRUE(HasWarning(warning_set, "extid2")); |
| 2140 EXPECT_EQ(3u, capturing_net_log.GetSize()); | 2140 EXPECT_EQ(3u, capturing_net_log.GetSize()); |
| 2141 } | 2141 } |
| 2142 | 2142 |
| 2143 } // namespace extensions | 2143 } // namespace extensions |
| OLD | NEW |