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

Side by Side Diff: chrome/browser/ui/cocoa/passwords/passwords_bubble_controller_unittest.mm

Issue 2040143006: Implement the Sync promo in the password bubble on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tests Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/ui/cocoa/passwords/passwords_bubble_controller.h" 5 #include "chrome/browser/ui/cocoa/passwords/passwords_bubble_controller.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/mac/foundation_util.h" 10 #include "base/mac/foundation_util.h"
11 #include "base/metrics/field_trial.h"
11 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/browser_window.h" 13 #include "chrome/browser/ui/browser_window.h"
13 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" 14 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h"
14 #import "chrome/browser/ui/cocoa/info_bubble_window.h" 15 #import "chrome/browser/ui/cocoa/info_bubble_window.h"
15 #include "chrome/browser/ui/cocoa/passwords/base_passwords_controller_test.h" 16 #include "chrome/browser/ui/cocoa/passwords/base_passwords_controller_test.h"
16 #import "chrome/browser/ui/cocoa/passwords/manage_passwords_view_controller.h" 17 #import "chrome/browser/ui/cocoa/passwords/manage_passwords_view_controller.h"
17 #import "chrome/browser/ui/cocoa/passwords/save_pending_password_view_controller .h" 18 #import "chrome/browser/ui/cocoa/passwords/save_pending_password_view_controller .h"
19 #import "chrome/browser/ui/cocoa/passwords/signin_promo_view_controller.h"
18 #import "chrome/browser/ui/cocoa/passwords/update_pending_password_view_controll er.h" 20 #import "chrome/browser/ui/cocoa/passwords/update_pending_password_view_controll er.h"
19 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" 21 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h"
20 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller_mock.h" 22 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller_mock.h"
23 #include "components/password_manager/core/browser/password_bubble_experiment.h"
24 #include "components/variations/variations_associated_data.h"
21 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
22 #include "testing/gtest_mac.h" 26 #include "testing/gtest_mac.h"
23 #include "testing/platform_test.h" 27 #include "testing/platform_test.h"
24 28
25 namespace { 29 namespace {
26 30
31 using password_bubble_experiment::kChromeSignInPasswordPromoExperimentName;
32 using password_bubble_experiment::kChromeSignInPasswordPromoThresholdParam;
33
27 class ManagePasswordsBubbleControllerTest 34 class ManagePasswordsBubbleControllerTest
28 : public ManagePasswordsControllerTest { 35 : public ManagePasswordsControllerTest {
29 public: 36 public:
30 ManagePasswordsBubbleControllerTest() : controller_(nil) {} 37 ManagePasswordsBubbleControllerTest() : controller_(nil) {}
31 38
32 void SetUp() override { ManagePasswordsControllerTest::SetUp(); }
33
34 ManagePasswordsBubbleController* controller() { 39 ManagePasswordsBubbleController* controller() {
35 if (!controller_) { 40 if (!controller_) {
36 controller_ = [[ManagePasswordsBubbleController alloc] 41 controller_ = [[ManagePasswordsBubbleController alloc]
37 initWithParentWindow:browser()->window()->GetNativeWindow() 42 initWithParentWindow:browser()->window()->GetNativeWindow()
38 model:GetModelAndCreateIfNull()]; 43 model:GetModelAndCreateIfNull()];
39 } 44 }
40 return controller_; 45 return controller_;
41 } 46 }
42 47
43 ManagePasswordsBubbleModel::DisplayReason GetDisplayReason() const override { 48 ManagePasswordsBubbleModel::DisplayReason GetDisplayReason() const override {
(...skipping 18 matching lines...) Expand all
62 base::scoped_nsobject<InfoBubbleWindow> window( 67 base::scoped_nsobject<InfoBubbleWindow> window(
63 [base::mac::ObjCCast<InfoBubbleWindow>([controller() window]) retain]); 68 [base::mac::ObjCCast<InfoBubbleWindow>([controller() window]) retain]);
64 [window setAllowedAnimations:info_bubble::kAnimateNone]; 69 [window setAllowedAnimations:info_bubble::kAnimateNone];
65 70
66 EXPECT_TRUE([window isVisible]); 71 EXPECT_TRUE([window isVisible]);
67 [controller() viewShouldDismiss]; 72 [controller() viewShouldDismiss];
68 EXPECT_FALSE([window isVisible]); 73 EXPECT_FALSE([window isVisible]);
69 } 74 }
70 75
71 TEST_F(ManagePasswordsBubbleControllerTest, ManageStateShouldHaveManageView) { 76 TEST_F(ManagePasswordsBubbleControllerTest, ManageStateShouldHaveManageView) {
72 SetUpManageState(); 77 SetUpManageState(VectorConstFormPtr());
73 EXPECT_EQ([ManagePasswordsViewController class], 78 EXPECT_EQ([ManagePasswordsViewController class],
74 [[controller() currentController] class]); 79 [[controller() currentController] class]);
75 } 80 }
76 81
77 TEST_F(ManagePasswordsBubbleControllerTest, 82 TEST_F(ManagePasswordsBubbleControllerTest,
78 PendingStateShouldHaveUpdatePendingView) { 83 PendingStateShouldHaveUpdatePendingView) {
79 SetUpUpdatePendingState(false); 84 SetUpUpdatePendingState(false);
80 EXPECT_EQ([UpdatePendingPasswordViewController class], 85 EXPECT_EQ([UpdatePendingPasswordViewController class],
81 [[controller() currentController] class]); 86 [[controller() currentController] class]);
82 } 87 }
83 88
84 TEST_F(ManagePasswordsBubbleControllerTest, ClearModelOnClose) { 89 TEST_F(ManagePasswordsBubbleControllerTest, ClearModelOnClose) {
85 SetUpUpdatePendingState(false); 90 SetUpUpdatePendingState(false);
86 EXPECT_TRUE(controller().model); 91 EXPECT_TRUE(controller().model);
87 [controller() close]; 92 [controller() close];
88 EXPECT_FALSE(controller().model); 93 EXPECT_FALSE(controller().model);
89 } 94 }
90 95
96 TEST_F(ManagePasswordsBubbleControllerTest, TransitionToSignInPromo) {
97 const char kFakeGroup[] = "FakeGroup";
98 base::FieldTrialList field_trial_list(nullptr);
99 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
100 kChromeSignInPasswordPromoExperimentName, kFakeGroup));
101 variations::AssociateVariationParams(
102 kChromeSignInPasswordPromoExperimentName, kFakeGroup,
103 {{kChromeSignInPasswordPromoThresholdParam, "3"}});
104
105 SetUpSavePendingState(false);
106 [controller() showWindow:nil];
107 SavePendingPasswordViewController* saveController =
108 base::mac::ObjCCastStrict<SavePendingPasswordViewController>(
109 [controller() currentController]);
110 EXPECT_TRUE(saveController.saveButton);
111 [saveController.saveButton performClick:nil];
112 EXPECT_EQ([SignInPromoViewController class],
113 [[controller() currentController] class]);
114 EXPECT_TRUE([[controller() window] isVisible]);
115
116 variations::testing::ClearAllVariationParams();
117 }
118
91 } // namespace 119 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698