| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/json/json_reader.h" | 6 #include "base/json/json_reader.h" |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/automation/extension_automation_constants.h" | 9 #include "chrome/browser/automation/extension_automation_constants.h" |
| 10 #include "chrome/browser/extensions/extension_tabs_module_constants.h" | 10 #include "chrome/browser/extensions/extension_tabs_module_constants.h" |
| 11 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 std::string result; | 156 std::string result; |
| 157 ASSERT_TRUE(message_dict->GetString(keys::kAutomationNameKey, &result)); | 157 ASSERT_TRUE(message_dict->GetString(keys::kAutomationNameKey, &result)); |
| 158 EXPECT_EQ(result, "tabs.remove"); | 158 EXPECT_EQ(result, "tabs.remove"); |
| 159 | 159 |
| 160 result = ""; | 160 result = ""; |
| 161 ASSERT_TRUE(message_dict->GetString(keys::kAutomationArgsKey, &result)); | 161 ASSERT_TRUE(message_dict->GetString(keys::kAutomationArgsKey, &result)); |
| 162 EXPECT_NE(result, ""); | 162 EXPECT_NE(result, ""); |
| 163 | 163 |
| 164 int callback_id = 0xBAADF00D; | 164 int callback_id = 0xBAADF00D; |
| 165 message_dict->GetInteger(keys::kAutomationRequestIdKey, &callback_id); | 165 message_dict->GetInteger(keys::kAutomationRequestIdKey, &callback_id); |
| 166 EXPECT_NE(callback_id, 0xBAADF00D); | 166 EXPECT_NE(callback_id, static_cast<int>(0xBAADF00D)); |
| 167 | 167 |
| 168 bool has_callback = true; | 168 bool has_callback = true; |
| 169 EXPECT_TRUE(message_dict->GetBoolean(keys::kAutomationHasCallbackKey, | 169 EXPECT_TRUE(message_dict->GetBoolean(keys::kAutomationHasCallbackKey, |
| 170 &has_callback)); | 170 &has_callback)); |
| 171 EXPECT_FALSE(has_callback); | 171 EXPECT_FALSE(has_callback); |
| 172 } | 172 } |
| 173 | 173 |
| 174 // A test that loads a basic extension that makes an API call that does | 174 // A test that loads a basic extension that makes an API call that does |
| 175 // not require a response. | 175 // not require a response. |
| 176 class ExtensionTestRoundtripApiCall : public ExtensionUITest { | 176 class ExtensionTestRoundtripApiCall : public ExtensionUITest { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 tab_->HandleMessageFromExternalHost( | 239 tab_->HandleMessageFromExternalHost( |
| 240 response_json, | 240 response_json, |
| 241 keys::kAutomationOrigin, | 241 keys::kAutomationOrigin, |
| 242 keys::kAutomationResponseTarget); | 242 keys::kAutomationResponseTarget); |
| 243 } else if (messages_received_ == 2) { | 243 } else if (messages_received_ == 2) { |
| 244 EXPECT_EQ(function_name, "tabs.remove"); | 244 EXPECT_EQ(function_name, "tabs.remove"); |
| 245 EXPECT_FALSE(has_callback); | 245 EXPECT_FALSE(has_callback); |
| 246 | 246 |
| 247 std::string args; | 247 std::string args; |
| 248 EXPECT_TRUE(request_dict->GetString(keys::kAutomationArgsKey, &args)); | 248 EXPECT_TRUE(request_dict->GetString(keys::kAutomationArgsKey, &args)); |
| 249 EXPECT_NE(args.find("42"), -1); | 249 EXPECT_NE(std::string::npos, args.find("42")); |
| 250 loop_.Quit(); | 250 loop_.Quit(); |
| 251 } else { | 251 } else { |
| 252 FAIL(); | 252 FAIL(); |
| 253 loop_.Quit(); | 253 loop_.Quit(); |
| 254 } | 254 } |
| 255 } | 255 } |
| 256 | 256 |
| 257 private: | 257 private: |
| 258 int messages_received_; | 258 int messages_received_; |
| 259 DISALLOW_COPY_AND_ASSIGN(ExtensionTestRoundtripApiCall); | 259 DISALLOW_COPY_AND_ASSIGN(ExtensionTestRoundtripApiCall); |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 ASSERT_EQ(arraysize(events_), event_count_.size()); | 482 ASSERT_EQ(arraysize(events_), event_count_.size()); |
| 483 for (std::map<std::string, int>::iterator i = event_count_.begin(); | 483 for (std::map<std::string, int>::iterator i = event_count_.begin(); |
| 484 i != event_count_.end(); ++i) { | 484 i != event_count_.end(); ++i) { |
| 485 const std::pair<std::string, int>& value = *i; | 485 const std::pair<std::string, int>& value = *i; |
| 486 EXPECT_EQ(1, value.second); | 486 EXPECT_EQ(1, value.second); |
| 487 } | 487 } |
| 488 } | 488 } |
| 489 #endif // defined(OS_WIN) | 489 #endif // defined(OS_WIN) |
| 490 | 490 |
| 491 } // namespace | 491 } // namespace |
| OLD | NEW |