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

Unified Diff: chrome/browser/ui/cocoa/web_intent_bubble_controller_unittest.mm

Issue 9307086: [Web Intents, Mac] Allow re-open after cancellation/close of picker bubble (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix review issue Created 8 years, 10 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/web_intent_bubble_controller_unittest.mm
diff --git a/chrome/browser/ui/cocoa/web_intent_bubble_controller_unittest.mm b/chrome/browser/ui/cocoa/web_intent_bubble_controller_unittest.mm
index 667e9164c112b1c6c7f5af60c4f37053499b140f..a39969e36fe18f783e3ef08ba5450e14c1ff1086 100644
--- a/chrome/browser/ui/cocoa/web_intent_bubble_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/web_intent_bubble_controller_unittest.mm
@@ -2,26 +2,26 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/basictypes.h"
#import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
#import "chrome/browser/ui/cocoa/hyperlink_button_cell.h"
#import "chrome/browser/ui/cocoa/info_bubble_window.h"
#import "chrome/browser/ui/cocoa/web_intent_bubble_controller.h"
#include "chrome/browser/ui/cocoa/web_intent_picker_cocoa.h"
#include "chrome/browser/ui/intents/web_intent_picker_delegate.h"
+#include "testing/gmock/include/gmock/gmock.h"
namespace {
-class FakeIntentPickerDelegate : public WebIntentPickerDelegate {
+class MockIntentPickerDelegate : public WebIntentPickerDelegate {
public:
- virtual ~FakeIntentPickerDelegate() {}
- virtual void OnServiceChosen(
- size_t index, Disposition disposition) OVERRIDE {};
- virtual void OnInlineDispositionWebContentsCreated(
- content::WebContents* web_contents) OVERRIDE {}
-
- // Callback called when the user cancels out of the dialog.
- virtual void OnCancelled() OVERRIDE {};
- virtual void OnClosing() OVERRIDE {};
+ virtual ~MockIntentPickerDelegate() {}
+
+ MOCK_METHOD2(OnServiceChosen,void(size_t index, Disposition disposition));
Robert Sesek 2012/02/08 15:54:47 nit: space after ',' and throughout this file
+ MOCK_METHOD1(OnInlineDispositionWebContentsCreated,
+ void(content::WebContents* web_contents));
+ MOCK_METHOD0(OnCancelled,void());
+ MOCK_METHOD0(OnClosing,void());
};
} // namespace
@@ -30,14 +30,29 @@ class WebIntentBubbleControllerTest : public CocoaTest {
public:
virtual void TearDown() {
// Do not animate out because that is hard to test around.
- [window_ setDelayOnClose:NO];
- [controller_ close];
+ if (window_)
+ [window_ setDelayOnClose:NO];
+
+ if (picker_.get()) {
+ EXPECT_CALL(delegate_,OnCancelled());
+ EXPECT_CALL(delegate_,OnClosing());
+
+ [controller_ close];
+ // Closing |controller_| destroys |picker_|.
+ ignore_result(picker_.release());
+ }
CocoaTest::TearDown();
}
- void CreateBubble() {
+ void CreatePicker() {
picker_.reset(new WebIntentPickerCocoa());
picker_->delegate_ = &delegate_;
+ window_ = nil;
+ controller_ = nil;
+ }
+
+ void CreateBubble() {
+ CreatePicker();
NSPoint anchor=NSMakePoint(0,0);
controller_ =
@@ -99,7 +114,7 @@ class WebIntentBubbleControllerTest : public CocoaTest {
WebIntentBubbleController* controller_; // Weak, owns self.
InfoBubbleWindow* window_; // Weak, owned by controller.
scoped_ptr<WebIntentPickerCocoa> picker_;
- FakeIntentPickerDelegate delegate_;
+ MockIntentPickerDelegate delegate_;
};
TEST_F(WebIntentBubbleControllerTest, EmptyBubble) {
@@ -119,3 +134,23 @@ TEST_F(WebIntentBubbleControllerTest, PopulatedBubble) {
CheckWindow(/*icon_count=*/2);
}
+
+TEST_F(WebIntentBubbleControllerTest, OnCancelledWillSignalClose) {
+ CreatePicker();
+
+ EXPECT_CALL(delegate_,OnCancelled());
+ EXPECT_CALL(delegate_,OnClosing());
+ picker_->OnCancelled();
+
+ ignore_result(picker_.release()); // Closing |picker_| will self-destruct it.
+}
+
+TEST_F(WebIntentBubbleControllerTest, CloseWillClose) {
+ CreateBubble();
+
+ EXPECT_CALL(delegate_,OnCancelled());
+ EXPECT_CALL(delegate_,OnClosing());
+ picker_->Close();
+
+ ignore_result(picker_.release()); // Closing |picker_| will self-destruct it.
+}
« no previous file with comments | « chrome/browser/ui/cocoa/web_intent_bubble_controller.mm ('k') | chrome/browser/ui/cocoa/web_intent_picker_cocoa.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698