OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/gfx/rect.h" | 6 #include "base/gfx/rect.h" |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/automation/extension_automation_constants.h" | 10 #include "chrome/browser/automation/extension_automation_constants.h" |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 bool has_callback = false; | 254 bool has_callback = false; |
255 EXPECT_TRUE(request_dict->GetBoolean(keys::kAutomationHasCallbackKey, | 255 EXPECT_TRUE(request_dict->GetBoolean(keys::kAutomationHasCallbackKey, |
256 &has_callback)); | 256 &has_callback)); |
257 | 257 |
258 if (messages_received_ == 1) { | 258 if (messages_received_ == 1) { |
259 EXPECT_EQ(function_name, "tabs.getSelected"); | 259 EXPECT_EQ(function_name, "tabs.getSelected"); |
260 EXPECT_GE(request_id, 0); | 260 EXPECT_GE(request_id, 0); |
261 EXPECT_TRUE(has_callback); | 261 EXPECT_TRUE(has_callback); |
262 | 262 |
263 DictionaryValue response_dict; | 263 DictionaryValue response_dict; |
264 EXPECT_TRUE(response_dict.SetInteger(keys::kAutomationRequestIdKey, | 264 response_dict.SetInteger(keys::kAutomationRequestIdKey, request_id); |
265 request_id)); | |
266 DictionaryValue tab_dict; | 265 DictionaryValue tab_dict; |
267 EXPECT_TRUE(tab_dict.SetInteger(extension_tabs_module_constants::kIdKey, | 266 tab_dict.SetInteger(extension_tabs_module_constants::kIdKey, 42); |
268 42)); | 267 tab_dict.SetInteger(extension_tabs_module_constants::kIndexKey, 1); |
269 EXPECT_TRUE(tab_dict.SetInteger( | 268 tab_dict.SetInteger(extension_tabs_module_constants::kWindowIdKey, 1); |
270 extension_tabs_module_constants::kIndexKey, 1)); | 269 tab_dict.SetBoolean(extension_tabs_module_constants::kSelectedKey, true); |
271 EXPECT_TRUE(tab_dict.SetInteger( | 270 tab_dict.SetString(extension_tabs_module_constants::kUrlKey, |
272 extension_tabs_module_constants::kWindowIdKey, 1)); | 271 "http://www.google.com"); |
273 EXPECT_TRUE(tab_dict.SetBoolean( | |
274 extension_tabs_module_constants::kSelectedKey, true)); | |
275 EXPECT_TRUE(tab_dict.SetString( | |
276 extension_tabs_module_constants::kUrlKey, "http://www.google.com")); | |
277 | 272 |
278 std::string tab_json; | 273 std::string tab_json; |
279 base::JSONWriter::Write(&tab_dict, false, &tab_json); | 274 base::JSONWriter::Write(&tab_dict, false, &tab_json); |
280 | 275 |
281 EXPECT_TRUE(response_dict.SetString(keys::kAutomationResponseKey, | 276 response_dict.SetString(keys::kAutomationResponseKey, tab_json); |
282 tab_json)); | |
283 | 277 |
284 std::string response_json; | 278 std::string response_json; |
285 base::JSONWriter::Write(&response_dict, false, &response_json); | 279 base::JSONWriter::Write(&response_dict, false, &response_json); |
286 | 280 |
287 tab_->HandleMessageFromExternalHost( | 281 tab_->HandleMessageFromExternalHost( |
288 response_json, | 282 response_json, |
289 keys::kAutomationOrigin, | 283 keys::kAutomationOrigin, |
290 keys::kAutomationResponseTarget); | 284 keys::kAutomationResponseTarget); |
291 } else if (messages_received_ == 2) { | 285 } else if (messages_received_ == 2) { |
292 EXPECT_EQ(function_name, "tabs.remove"); | 286 EXPECT_EQ(function_name, "tabs.remove"); |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 proxy->event_count_.size()); | 516 proxy->event_count_.size()); |
523 for (std::map<std::string, int>::iterator i = proxy->event_count_.begin(); | 517 for (std::map<std::string, int>::iterator i = proxy->event_count_.begin(); |
524 i != proxy->event_count_.end(); ++i) { | 518 i != proxy->event_count_.end(); ++i) { |
525 const std::pair<std::string, int>& value = *i; | 519 const std::pair<std::string, int>& value = *i; |
526 ASSERT_EQ(1, value.second); | 520 ASSERT_EQ(1, value.second); |
527 } | 521 } |
528 } | 522 } |
529 #endif // defined(OS_WIN) | 523 #endif // defined(OS_WIN) |
530 | 524 |
531 } // namespace | 525 } // namespace |
OLD | NEW |