OLD | NEW |
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 "base/metrics/histogram_samples.h" | 5 #include "base/metrics/histogram_samples.h" |
6 #include "base/prefs/pref_service.h" | 6 #include "base/prefs/pref_service.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "base/test/histogram_tester.h" | 8 #include "base/test/histogram_tester.h" |
9 #include "chrome/browser/ui/passwords/manage_passwords_bubble.h" | 9 #include "chrome/browser/ui/passwords/manage_passwords_bubble.h" |
10 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" | 10 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" |
11 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller_mock.h" | 11 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller_mock.h" |
12 #include "chrome/test/base/testing_profile.h" | 12 #include "chrome/test/base/testing_profile.h" |
13 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" | 13 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" |
14 #include "components/password_manager/core/common/password_manager_ui.h" | 14 #include "components/password_manager/core/common/password_manager_ui.h" |
15 #include "content/public/test/test_browser_thread_bundle.h" | 15 #include "content/public/test/test_browser_thread_bundle.h" |
16 #include "content/public/test/web_contents_tester.h" | 16 #include "content/public/test/web_contents_tester.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 | 18 |
19 const char kUIDismissalReasonMetric[] = "PasswordManager.UIDismissalReason"; | 19 const char kUIDismissalReasonMetric[] = "PasswordManager.UIDismissalReason"; |
20 | 20 |
21 class ManagePasswordsBubbleModelTest : public testing::Test { | 21 class ManagePasswordsBubbleModelTest : public testing::Test { |
22 public: | 22 public: |
23 ManagePasswordsBubbleModelTest() | 23 ManagePasswordsBubbleModelTest() |
24 : test_web_contents_( | 24 : test_web_contents_( |
25 content::WebContentsTester::CreateTestWebContents(&profile_, | 25 content::WebContentsTester::CreateTestWebContents(&profile_, |
26 NULL)) {} | 26 NULL)) {} |
27 | 27 |
28 virtual void SetUp() OVERRIDE { | 28 virtual void SetUp() override { |
29 // Create the test UIController here so that it's bound to | 29 // Create the test UIController here so that it's bound to |
30 // |test_web_contents_| and therefore accessible to the model. | 30 // |test_web_contents_| and therefore accessible to the model. |
31 new ManagePasswordsUIControllerMock(test_web_contents_.get()); | 31 new ManagePasswordsUIControllerMock(test_web_contents_.get()); |
32 | 32 |
33 model_.reset(new ManagePasswordsBubbleModel(test_web_contents_.get())); | 33 model_.reset(new ManagePasswordsBubbleModel(test_web_contents_.get())); |
34 } | 34 } |
35 | 35 |
36 virtual void TearDown() OVERRIDE { model_.reset(); } | 36 virtual void TearDown() override { model_.reset(); } |
37 | 37 |
38 void PretendPasswordWaiting() { | 38 void PretendPasswordWaiting() { |
39 model_->set_state(password_manager::ui::PENDING_PASSWORD_AND_BUBBLE_STATE); | 39 model_->set_state(password_manager::ui::PENDING_PASSWORD_AND_BUBBLE_STATE); |
40 model_->OnBubbleShown(ManagePasswordsBubble::AUTOMATIC); | 40 model_->OnBubbleShown(ManagePasswordsBubble::AUTOMATIC); |
41 controller()->SetState( | 41 controller()->SetState( |
42 password_manager::ui::PENDING_PASSWORD_AND_BUBBLE_STATE); | 42 password_manager::ui::PENDING_PASSWORD_AND_BUBBLE_STATE); |
43 } | 43 } |
44 | 44 |
45 void PretendManagingPasswords() { | 45 void PretendManagingPasswords() { |
46 model_->set_state(password_manager::ui::MANAGE_STATE); | 46 model_->set_state(password_manager::ui::MANAGE_STATE); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 model_->set_state(password_manager::ui::MANAGE_STATE); | 225 model_->set_state(password_manager::ui::MANAGE_STATE); |
226 EXPECT_FALSE(password_manager::ui::IsPendingState(model_->state())); | 226 EXPECT_FALSE(password_manager::ui::IsPendingState(model_->state())); |
227 model_->set_state(password_manager::ui::BLACKLIST_STATE); | 227 model_->set_state(password_manager::ui::BLACKLIST_STATE); |
228 EXPECT_FALSE(password_manager::ui::IsPendingState(model_->state())); | 228 EXPECT_FALSE(password_manager::ui::IsPendingState(model_->state())); |
229 | 229 |
230 model_->set_state(password_manager::ui::PENDING_PASSWORD_AND_BUBBLE_STATE); | 230 model_->set_state(password_manager::ui::PENDING_PASSWORD_AND_BUBBLE_STATE); |
231 EXPECT_TRUE(password_manager::ui::IsPendingState(model_->state())); | 231 EXPECT_TRUE(password_manager::ui::IsPendingState(model_->state())); |
232 model_->set_state(password_manager::ui::PENDING_PASSWORD_STATE); | 232 model_->set_state(password_manager::ui::PENDING_PASSWORD_STATE); |
233 EXPECT_TRUE(password_manager::ui::IsPendingState(model_->state())); | 233 EXPECT_TRUE(password_manager::ui::IsPendingState(model_->state())); |
234 } | 234 } |
OLD | NEW |