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

Unified Diff: chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_controller_unittest.mm

Issue 422233009: Add ManagePasswordsBubbleController and unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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/passwords/manage_passwords_bubble_controller_unittest.mm
diff --git a/chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_controller_unittest.mm b/chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_controller_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..19fe40eb341af80dccef018a13d0bee34223e6b1
--- /dev/null
+++ b/chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_controller_unittest.mm
@@ -0,0 +1,64 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_controller.h"
+
+#import <Cocoa/Cocoa.h>
+
+#include "base/compiler_specific.h"
+#include "base/mac/foundation_util.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/cocoa/cocoa_test_helper.h"
+#import "chrome/browser/ui/cocoa/info_bubble_window.h"
+#include "chrome/browser/ui/cocoa/passwords/manage_passwords_controller_test.h"
+#include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/gtest_mac.h"
+#include "testing/platform_test.h"
+
+class ManagePasswordsBubbleControllerTest
Scott Hess - ex-Googler 2014/08/20 20:04:41 Hmm, forgot to ask about previous reviews: Will al
dconnelly 2014/08/21 08:47:59 Apparently it will. I've updated all the unit test
+ : public ManagePasswordsControllerTest {
+ public:
+ ManagePasswordsBubbleControllerTest() : controller_(nil) {}
+
+ virtual void SetUp() OVERRIDE {
+ ManagePasswordsControllerTest::SetUp();
+ model()->set_state(password_manager::ui::PENDING_PASSWORD_STATE);
+ }
+
+ ManagePasswordsBubbleController* controller() {
+ if (!controller_) {
+ controller_ = [[ManagePasswordsBubbleController alloc]
+ initWithParentWindow:browser()->window()->GetNativeWindow()
+ model:model()];
+ }
+ return controller_;
+ }
+
+ private:
+ ManagePasswordsBubbleController* controller_; // weak; owns itself.
+};
+
+TEST_F(ManagePasswordsBubbleControllerTest, PendingStateShouldHavePendingView) {
+ // We start in the pending state.
+ EXPECT_EQ([ManagePasswordsBubblePendingViewController class],
+ [[controller() currentController] class]);
+}
+
+TEST_F(ManagePasswordsBubbleControllerTest, DismissingShouldCloseWindow) {
+ [controller() showWindow:nil];
+
+ // Turn off animations so that closing happens immediately.
+ InfoBubbleWindow* window =
+ base::mac::ObjCCast<InfoBubbleWindow>([controller() window]);
+ [window setAllowedAnimations:info_bubble::kAnimateNone];
+
+ // Retain the controller, as it will release itself when closed.
+ base::scoped_nsobject<ManagePasswordsBubbleController> strongController(
+ [controller() retain]);
+ EXPECT_TRUE([[strongController window] isVisible]);
+ [strongController viewShouldDismiss];
+ EXPECT_FALSE([[strongController window] isVisible]);
Scott Hess - ex-Googler 2014/08/20 20:04:40 This depends on the controller keeping a reference
dconnelly 2014/08/21 08:47:59 Done.
+}

Powered by Google App Engine
This is Rietveld 408576698