| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/test/test_timeouts.h" |
| 8 #include "base/values.h" | 9 #include "base/values.h" |
| 9 #include "chrome/browser/automation/extension_automation_constants.h" | 10 #include "chrome/browser/automation/extension_automation_constants.h" |
| 10 #include "chrome/browser/extensions/extension_tabs_module_constants.h" | 11 #include "chrome/browser/extensions/extension_tabs_module_constants.h" |
| 11 #include "chrome/common/automation_messages.h" | 12 #include "chrome/common/automation_messages.h" |
| 12 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 13 #include "chrome/common/extensions/extension.h" | 14 #include "chrome/common/extensions/extension.h" |
| 14 #include "chrome/test/automation/automation_proxy_uitest.h" | 15 #include "chrome/test/automation/automation_proxy_uitest.h" |
| 15 #include "chrome/test/automation/tab_proxy.h" | 16 #include "chrome/test/automation/tab_proxy.h" |
| 16 #include "chrome/test/ui/ui_test.h" | 17 #include "chrome/test/ui/ui_test.h" |
| 17 #include "chrome/test/ui_test_utils.h" | 18 #include "chrome/test/ui_test_utils.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 SaveArg<0>(&message_received), | 138 SaveArg<0>(&message_received), |
| 138 InvokeWithoutArgs( | 139 InvokeWithoutArgs( |
| 139 CreateFunctor(&loop_, &TimedMessageLoopRunner::Quit)))); | 140 CreateFunctor(&loop_, &TimedMessageLoopRunner::Quit)))); |
| 140 | 141 |
| 141 EXPECT_CALL(*mock_, HandleClosed(_)); | 142 EXPECT_CALL(*mock_, HandleClosed(_)); |
| 142 | 143 |
| 143 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab_->NavigateInExternalTab( | 144 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab_->NavigateInExternalTab( |
| 144 GURL("chrome-extension://pmgpglkggjdpkpghhdmbdhababjpcohk/test.html"), | 145 GURL("chrome-extension://pmgpglkggjdpkpghhdmbdhababjpcohk/test.html"), |
| 145 GURL(""))); | 146 GURL(""))); |
| 146 | 147 |
| 147 loop_.RunFor(action_max_timeout_ms()); | 148 loop_.RunFor(TestTimeouts::action_max_timeout_ms()); |
| 148 ASSERT_FALSE(message_received.empty()); | 149 ASSERT_FALSE(message_received.empty()); |
| 149 | 150 |
| 150 scoped_ptr<Value> message_value(base::JSONReader::Read(message_received, | 151 scoped_ptr<Value> message_value(base::JSONReader::Read(message_received, |
| 151 false)); | 152 false)); |
| 152 ASSERT_TRUE(message_value->IsType(Value::TYPE_DICTIONARY)); | 153 ASSERT_TRUE(message_value->IsType(Value::TYPE_DICTIONARY)); |
| 153 DictionaryValue* message_dict = | 154 DictionaryValue* message_dict = |
| 154 reinterpret_cast<DictionaryValue*>(message_value.get()); | 155 reinterpret_cast<DictionaryValue*>(message_value.get()); |
| 155 std::string result; | 156 std::string result; |
| 156 ASSERT_TRUE(message_dict->GetString(keys::kAutomationNameKey, &result)); | 157 ASSERT_TRUE(message_dict->GetString(keys::kAutomationNameKey, &result)); |
| 157 EXPECT_EQ("tabs.remove", result); | 158 EXPECT_EQ("tabs.remove", result); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 &ExtensionTestRoundtripApiCall::CheckAndSendResponse)))); | 291 &ExtensionTestRoundtripApiCall::CheckAndSendResponse)))); |
| 291 | 292 |
| 292 EXPECT_CALL(*mock_, HandleClosed(_)); | 293 EXPECT_CALL(*mock_, HandleClosed(_)); |
| 293 | 294 |
| 294 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab_->NavigateInExternalTab( | 295 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab_->NavigateInExternalTab( |
| 295 GURL("chrome-extension://ofoknjclcmghjfmbncljcnpjmfmldhno/test.html"), | 296 GURL("chrome-extension://ofoknjclcmghjfmbncljcnpjmfmldhno/test.html"), |
| 296 GURL(""))); | 297 GURL(""))); |
| 297 | 298 |
| 298 // CheckAndSendResponse (called by OnForwardMessageToExternalHost) | 299 // CheckAndSendResponse (called by OnForwardMessageToExternalHost) |
| 299 // will end the loop once it has received both of our expected messages. | 300 // will end the loop once it has received both of our expected messages. |
| 300 loop_.RunFor(action_max_timeout_ms()); | 301 loop_.RunFor(TestTimeouts::action_max_timeout_ms()); |
| 301 } | 302 } |
| 302 | 303 |
| 303 class ExtensionTestBrowserEvents : public ExtensionUITest { | 304 class ExtensionTestBrowserEvents : public ExtensionUITest { |
| 304 public: | 305 public: |
| 305 ExtensionTestBrowserEvents() | 306 ExtensionTestBrowserEvents() |
| 306 : ExtensionUITest(kTestDirectoryBrowserEvent), | 307 : ExtensionUITest(kTestDirectoryBrowserEvent), |
| 307 response_count_(0) { | 308 response_count_(0) { |
| 308 } | 309 } |
| 309 | 310 |
| 310 void SetUp() { | 311 void SetUp() { |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 &ExtensionTestBrowserEvents::HandleMessageFromChrome)))); | 478 &ExtensionTestBrowserEvents::HandleMessageFromChrome)))); |
| 478 | 479 |
| 479 EXPECT_CALL(*mock_, HandleClosed(_)); | 480 EXPECT_CALL(*mock_, HandleClosed(_)); |
| 480 | 481 |
| 481 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab_->NavigateInExternalTab( | 482 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab_->NavigateInExternalTab( |
| 482 GURL("chrome-extension://ofoknjclcmghjfmbncljcnpjmfmldhno/test.html"), | 483 GURL("chrome-extension://ofoknjclcmghjfmbncljcnpjmfmldhno/test.html"), |
| 483 GURL(""))); | 484 GURL(""))); |
| 484 | 485 |
| 485 // HandleMessageFromChrome (called by OnForwardMessageToExternalHost) ends | 486 // HandleMessageFromChrome (called by OnForwardMessageToExternalHost) ends |
| 486 // the loop when we've received the number of response messages we expect. | 487 // the loop when we've received the number of response messages we expect. |
| 487 loop_.RunFor(action_max_timeout_ms()); | 488 loop_.RunFor(TestTimeouts::action_max_timeout_ms()); |
| 488 | 489 |
| 489 // If this assert hits and the actual size is 0 then you need to look at: | 490 // If this assert hits and the actual size is 0 then you need to look at: |
| 490 // src\chrome\test\data\extensions\uitest\event_sink\test.html and see if | 491 // src\chrome\test\data\extensions\uitest\event_sink\test.html and see if |
| 491 // all the events we are attaching to are valid. Also compare the list against | 492 // all the events we are attaching to are valid. Also compare the list against |
| 492 // the event_names_ string array above. | 493 // the event_names_ string array above. |
| 493 ASSERT_EQ(arraysize(events_), event_count_.size()); | 494 ASSERT_EQ(arraysize(events_), event_count_.size()); |
| 494 for (std::map<std::string, int>::iterator i = event_count_.begin(); | 495 for (std::map<std::string, int>::iterator i = event_count_.begin(); |
| 495 i != event_count_.end(); ++i) { | 496 i != event_count_.end(); ++i) { |
| 496 const std::pair<std::string, int>& value = *i; | 497 const std::pair<std::string, int>& value = *i; |
| 497 EXPECT_EQ(1, value.second); | 498 EXPECT_EQ(1, value.second); |
| 498 } | 499 } |
| 499 } | 500 } |
| 500 #endif // defined(OS_WIN) | 501 #endif // defined(OS_WIN) |
| 501 | 502 |
| 502 } // namespace | 503 } // namespace |
| OLD | NEW |