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

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

Issue 479123003: Add ManagePasswordsBubbleConfirmationViewController 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_confirmation_view_controller_unittest.mm
diff --git a/chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_confirmation_view_controller_unittest.mm b/chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_confirmation_view_controller_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..02175bcbc4722b50969c48767372f4139e6d5591
--- /dev/null
+++ b/chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_confirmation_view_controller_unittest.mm
@@ -0,0 +1,82 @@
+// 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.
+
+#import "chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_confirmation_view_controller.h"
+
+#include "base/mac/scoped_nsobject.h"
+#include "base/strings/string16.h"
+#include "base/strings/utf_string_conversions.h"
+#import "chrome/browser/ui/cocoa/bubble_combobox.h"
+#include "chrome/browser/ui/cocoa/cocoa_test_helper.h"
+#include "chrome/browser/ui/cocoa/passwords/manage_passwords_controller_test.h"
+#include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h"
+#include "chrome/browser/ui/passwords/manage_passwords_ui_controller_mock.h"
+#include "chrome/browser/ui/passwords/save_password_refusal_combobox_model.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/gtest_mac.h"
+
+@interface ManagePasswordsBubbleContentViewTestDelegate
+ : NSObject<ManagePasswordsBubbleContentViewDelegate> {
+ BOOL dismissed_;
+}
+@property(readonly) BOOL dismissed;
+@end
+
+@implementation ManagePasswordsBubbleContentViewTestDelegate
+
+@synthesize dismissed = dismissed_;
+
+- (void)viewShouldDismiss {
+ dismissed_ = YES;
+}
+
+@end
+
+namespace {
+
+class ManagePasswordsBubbleConfirmationViewControllerTest
+ : public ManagePasswordsControllerTest {
+ public:
+ ManagePasswordsBubbleConfirmationViewControllerTest() : controller_(nil) {}
+
+ virtual void SetUp() OVERRIDE {
+ ManagePasswordsControllerTest::SetUp();
+ delegate_.reset(
+ [[ManagePasswordsBubbleContentViewTestDelegate alloc] init]);
+ }
+
+ ManagePasswordsBubbleContentViewTestDelegate* delegate() {
+ return delegate_.get();
+ }
+
+ ManagePasswordsBubbleConfirmationViewController* controller() {
+ if (!controller_) {
+ controller_.reset([[ManagePasswordsBubbleConfirmationViewController alloc]
+ initWithModel:model()
+ delegate:delegate()]);
+ [controller_ loadView];
+ }
+ return controller_.get();
+ }
+
+ private:
+ base::scoped_nsobject<ManagePasswordsBubbleConfirmationViewController>
+ controller_;
+ base::scoped_nsobject<ManagePasswordsBubbleContentViewTestDelegate> delegate_;
+};
+
+TEST_F(ManagePasswordsBubbleConfirmationViewControllerTest,
+ ShouldDismissWhenOKClicked) {
+ [controller().okButton performClick:nil];
+ EXPECT_TRUE([delegate() dismissed]);
+}
+
+TEST_F(ManagePasswordsBubbleConfirmationViewControllerTest,
+ ShouldOpenPasswordsAndDismissWhenLinkClicked) {
+ [controller().confirmationText clickedOnLink:nil atIndex:0];
+ EXPECT_TRUE([delegate() dismissed]);
+ EXPECT_TRUE(ui_controller()->navigated_to_account_central_management_page());
+}
+
+} // namespace

Powered by Google App Engine
This is Rietveld 408576698