| OLD | NEW |
| 1 // Copyright (c) 2010 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" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 private: | 120 private: |
| 121 DISALLOW_COPY_AND_ASSIGN(ExtensionTestSimpleApiCall); | 121 DISALLOW_COPY_AND_ASSIGN(ExtensionTestSimpleApiCall); |
| 122 }; | 122 }; |
| 123 | 123 |
| 124 // Flaky: http://crbug.com/44599 | 124 // Flaky: http://crbug.com/44599 |
| 125 TEST_F(ExtensionTestSimpleApiCall, FLAKY_RunTest) { | 125 TEST_F(ExtensionTestSimpleApiCall, FLAKY_RunTest) { |
| 126 namespace keys = extension_automation_constants; | 126 namespace keys = extension_automation_constants; |
| 127 | 127 |
| 128 ASSERT_THAT(mock_, testing::NotNull()); | 128 ASSERT_THAT(mock_, testing::NotNull()); |
| 129 EXPECT_CALL(*mock_, OnDidNavigate(_, _)).Times(1); | 129 EXPECT_CALL(*mock_, OnDidNavigate(_)).Times(1); |
| 130 EXPECT_CALL(*mock_, OnNavigationStateChanged(_, _, _)) | 130 EXPECT_CALL(*mock_, OnNavigationStateChanged(_, _)) |
| 131 .Times(testing::AnyNumber()); | 131 .Times(testing::AnyNumber()); |
| 132 | 132 |
| 133 std::string message_received; | 133 std::string message_received; |
| 134 EXPECT_CALL(*mock_, OnForwardMessageToExternalHost( | 134 EXPECT_CALL(*mock_, OnForwardMessageToExternalHost( |
| 135 _, _, keys::kAutomationOrigin, keys::kAutomationRequestTarget)) | 135 _, keys::kAutomationOrigin, keys::kAutomationRequestTarget)) |
| 136 .WillOnce(DoAll( | 136 .WillOnce(DoAll( |
| 137 SaveArg<1>(&message_received), | 137 SaveArg<1>(&message_received), |
| 138 InvokeWithoutArgs( | 138 InvokeWithoutArgs( |
| 139 CreateFunctor(&loop_, &TimedMessageLoopRunner::Quit)))); | 139 CreateFunctor(&loop_, &TimedMessageLoopRunner::Quit)))); |
| 140 | 140 |
| 141 EXPECT_CALL(*mock_, HandleClosed(_)); | 141 EXPECT_CALL(*mock_, HandleClosed(_)); |
| 142 | 142 |
| 143 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab_->NavigateInExternalTab( | 143 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab_->NavigateInExternalTab( |
| 144 GURL("chrome-extension://pmgpglkggjdpkpghhdmbdhababjpcohk/test.html"), | 144 GURL("chrome-extension://pmgpglkggjdpkpghhdmbdhababjpcohk/test.html"), |
| 145 GURL(""))); | 145 GURL(""))); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 int messages_received_; | 270 int messages_received_; |
| 271 DISALLOW_COPY_AND_ASSIGN(ExtensionTestRoundtripApiCall); | 271 DISALLOW_COPY_AND_ASSIGN(ExtensionTestRoundtripApiCall); |
| 272 }; | 272 }; |
| 273 | 273 |
| 274 // This is flaky on XP Tests (dbg)(2) bot. | 274 // This is flaky on XP Tests (dbg)(2) bot. |
| 275 // http://code.google.com/p/chromium/issues/detail?id=44650 | 275 // http://code.google.com/p/chromium/issues/detail?id=44650 |
| 276 TEST_F(ExtensionTestRoundtripApiCall, FLAKY_RunTest) { | 276 TEST_F(ExtensionTestRoundtripApiCall, FLAKY_RunTest) { |
| 277 namespace keys = extension_automation_constants; | 277 namespace keys = extension_automation_constants; |
| 278 | 278 |
| 279 ASSERT_THAT(mock_, testing::NotNull()); | 279 ASSERT_THAT(mock_, testing::NotNull()); |
| 280 EXPECT_CALL(*mock_, OnDidNavigate(_, _)).Times(1); | 280 EXPECT_CALL(*mock_, OnDidNavigate(_)).Times(1); |
| 281 EXPECT_CALL(*mock_, OnNavigationStateChanged(_, _, _)) | 281 EXPECT_CALL(*mock_, OnNavigationStateChanged(_, _)) |
| 282 .Times(testing::AnyNumber()); | 282 .Times(testing::AnyNumber()); |
| 283 EXPECT_CALL(*mock_, OnLoad(_, _)).Times(testing::AnyNumber()); | 283 EXPECT_CALL(*mock_, OnLoad(_)).Times(testing::AnyNumber()); |
| 284 | 284 |
| 285 EXPECT_CALL(*mock_, OnForwardMessageToExternalHost( | 285 EXPECT_CALL(*mock_, OnForwardMessageToExternalHost( |
| 286 _, _, keys::kAutomationOrigin, keys::kAutomationRequestTarget)) | 286 _, keys::kAutomationOrigin, keys::kAutomationRequestTarget)) |
| 287 .Times(2) | 287 .Times(2) |
| 288 .WillRepeatedly(WithArgs<1>(Invoke( | 288 .WillRepeatedly(WithArgs<1>(Invoke( |
| 289 CreateFunctor(this, | 289 CreateFunctor(this, |
| 290 &ExtensionTestRoundtripApiCall::CheckAndSendResponse)))); | 290 &ExtensionTestRoundtripApiCall::CheckAndSendResponse)))); |
| 291 | 291 |
| 292 EXPECT_CALL(*mock_, HandleClosed(_)); | 292 EXPECT_CALL(*mock_, HandleClosed(_)); |
| 293 | 293 |
| 294 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab_->NavigateInExternalTab( | 294 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab_->NavigateInExternalTab( |
| 295 GURL("chrome-extension://ofoknjclcmghjfmbncljcnpjmfmldhno/test.html"), | 295 GURL("chrome-extension://ofoknjclcmghjfmbncljcnpjmfmldhno/test.html"), |
| 296 GURL(""))); | 296 GURL(""))); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 } | 458 } |
| 459 | 459 |
| 460 // Flaky, http://crbug.com/37554. | 460 // Flaky, http://crbug.com/37554. |
| 461 TEST_F(ExtensionTestBrowserEvents, FLAKY_RunTest) { | 461 TEST_F(ExtensionTestBrowserEvents, FLAKY_RunTest) { |
| 462 // This test loads an HTML file that tries to add listeners to a bunch of | 462 // This test loads an HTML file that tries to add listeners to a bunch of |
| 463 // chrome.* events and upon adding a listener it posts the name of the event | 463 // chrome.* events and upon adding a listener it posts the name of the event |
| 464 // to the automation layer, which we'll count to make sure the events work. | 464 // to the automation layer, which we'll count to make sure the events work. |
| 465 namespace keys = extension_automation_constants; | 465 namespace keys = extension_automation_constants; |
| 466 | 466 |
| 467 ASSERT_THAT(mock_, testing::NotNull()); | 467 ASSERT_THAT(mock_, testing::NotNull()); |
| 468 EXPECT_CALL(*mock_, OnDidNavigate(_, _)).Times(1); | 468 EXPECT_CALL(*mock_, OnDidNavigate(_)).Times(1); |
| 469 EXPECT_CALL(*mock_, OnNavigationStateChanged(_, _, _)) | 469 EXPECT_CALL(*mock_, OnNavigationStateChanged(_, _)) |
| 470 .Times(testing::AnyNumber()); | 470 .Times(testing::AnyNumber()); |
| 471 EXPECT_CALL(*mock_, OnLoad(_, _)).Times(testing::AnyNumber()); | 471 EXPECT_CALL(*mock_, OnLoad(_)).Times(testing::AnyNumber()); |
| 472 | 472 |
| 473 EXPECT_CALL(*mock_, OnForwardMessageToExternalHost( | 473 EXPECT_CALL(*mock_, OnForwardMessageToExternalHost( |
| 474 _, _, keys::kAutomationOrigin, _)) | 474 _, keys::kAutomationOrigin, _)) |
| 475 .WillRepeatedly(WithArgs<1, 3>(Invoke( | 475 .WillRepeatedly(WithArgs<1, 2>(Invoke( |
| 476 CreateFunctor(this, | 476 CreateFunctor(this, |
| 477 &ExtensionTestBrowserEvents::HandleMessageFromChrome)))); | 477 &ExtensionTestBrowserEvents::HandleMessageFromChrome)))); |
| 478 | 478 |
| 479 EXPECT_CALL(*mock_, HandleClosed(_)); | 479 EXPECT_CALL(*mock_, HandleClosed(_)); |
| 480 | 480 |
| 481 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab_->NavigateInExternalTab( | 481 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab_->NavigateInExternalTab( |
| 482 GURL("chrome-extension://ofoknjclcmghjfmbncljcnpjmfmldhno/test.html"), | 482 GURL("chrome-extension://ofoknjclcmghjfmbncljcnpjmfmldhno/test.html"), |
| 483 GURL(""))); | 483 GURL(""))); |
| 484 | 484 |
| 485 // HandleMessageFromChrome (called by OnForwardMessageToExternalHost) ends | 485 // HandleMessageFromChrome (called by OnForwardMessageToExternalHost) ends |
| 486 // the loop when we've received the number of response messages we expect. | 486 // the loop when we've received the number of response messages we expect. |
| 487 loop_.RunFor(action_max_timeout_ms()); | 487 loop_.RunFor(action_max_timeout_ms()); |
| 488 | 488 |
| 489 // If this assert hits and the actual size is 0 then you need to look at: | 489 // 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 | 490 // 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 | 491 // all the events we are attaching to are valid. Also compare the list against |
| 492 // the event_names_ string array above. | 492 // the event_names_ string array above. |
| 493 ASSERT_EQ(arraysize(events_), event_count_.size()); | 493 ASSERT_EQ(arraysize(events_), event_count_.size()); |
| 494 for (std::map<std::string, int>::iterator i = event_count_.begin(); | 494 for (std::map<std::string, int>::iterator i = event_count_.begin(); |
| 495 i != event_count_.end(); ++i) { | 495 i != event_count_.end(); ++i) { |
| 496 const std::pair<std::string, int>& value = *i; | 496 const std::pair<std::string, int>& value = *i; |
| 497 EXPECT_EQ(1, value.second); | 497 EXPECT_EQ(1, value.second); |
| 498 } | 498 } |
| 499 } | 499 } |
| 500 #endif // defined(OS_WIN) | 500 #endif // defined(OS_WIN) |
| 501 | 501 |
| 502 } // namespace | 502 } // namespace |
| OLD | NEW |