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

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..6956200ab2a4e10a3fa4c7ace91f7ead2a9481fe
--- /dev/null
+++ b/chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_controller_unittest.mm
@@ -0,0 +1,65 @@
+// 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"
+
+namespace {
+
+class ManagePasswordsBubbleControllerTest
+ : 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.
+ base::scoped_nsobject<InfoBubbleWindow> window(
+ [base::mac::ObjCCast<InfoBubbleWindow>([controller() window]) retain]);
+ [window setAllowedAnimations:info_bubble::kAnimateNone];
+
+ EXPECT_TRUE([window isVisible]);
+ [controller() viewShouldDismiss];
+ EXPECT_FALSE([window isVisible]);
+}
+
+} // namespace

Powered by Google App Engine
This is Rietveld 408576698