Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(742)

Side by Side Diff: chrome/browser/extensions/extension_uitest.cc

Issue 6010005: Fix problems with my previous patch (r70105) with gmock. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
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<0>(&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("")));
146 146
147 loop_.RunFor(action_max_timeout_ms()); 147 loop_.RunFor(action_max_timeout_ms());
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
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<0>(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("")));
297 297
298 // CheckAndSendResponse (called by OnForwardMessageToExternalHost) 298 // CheckAndSendResponse (called by OnForwardMessageToExternalHost)
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, 2>(Invoke( 475 .WillRepeatedly(WithArgs<0, 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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698