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

Side by Side Diff: ui/message_center/views/notifier_settings_view_unittest.cc

Issue 1878973002: [reland] Makes MaterialDesignController initialization explicit (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Made it possible to restore MaterialDesignController state after each test case (nits) Created 4 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/message_center/fake_notifier_settings_provider.h" 10 #include "ui/message_center/fake_notifier_settings_provider.h"
11 #include "ui/message_center/views/notifier_settings_view.h" 11 #include "ui/message_center/views/notifier_settings_view.h"
12 #include "ui/views/test/views_test_base.h"
12 13
13 namespace message_center { 14 namespace message_center {
14 15
15 namespace { 16 namespace {
16 17
17 Notifier* NewNotifier(const std::string& id, 18 Notifier* NewNotifier(const std::string& id,
18 const std::string& title, 19 const std::string& title,
19 bool enabled) { 20 bool enabled) {
20 NotifierId notifier_id(NotifierId::APPLICATION, id); 21 NotifierId notifier_id(NotifierId::APPLICATION, id);
21 return new Notifier(notifier_id, base::UTF8ToUTF16(title), enabled); 22 return new Notifier(notifier_id, base::UTF8ToUTF16(title), enabled);
(...skipping 29 matching lines...) Expand all
51 } 52 }
52 53
53 private: 54 private:
54 NotifierId settings_handler_id_; 55 NotifierId settings_handler_id_;
55 size_t request_count_; 56 size_t request_count_;
56 std::unique_ptr<NotifierId> last_notifier_id_settings_requested_; 57 std::unique_ptr<NotifierId> last_notifier_id_settings_requested_;
57 }; 58 };
58 59
59 } // namespace 60 } // namespace
60 61
61 class NotifierSettingsViewTest : public testing::Test { 62 class NotifierSettingsViewTest : public views::ViewsTestBase {
62 public: 63 public:
63 NotifierSettingsViewTest(); 64 NotifierSettingsViewTest();
64 ~NotifierSettingsViewTest() override; 65 ~NotifierSettingsViewTest() override;
65 66
66 void SetUp() override; 67 void SetUp() override;
67 void TearDown() override; 68 void TearDown() override;
68 69
69 NotifierSettingsView* GetView() const; 70 NotifierSettingsView* GetView() const;
70 TestingNotifierSettingsProvider* settings_provider() const { 71 TestingNotifierSettingsProvider* settings_provider() const {
71 return settings_provider_.get(); 72 return settings_provider_.get();
72 } 73 }
73 74
74 private: 75 private:
75 std::unique_ptr<TestingNotifierSettingsProvider> settings_provider_; 76 std::unique_ptr<TestingNotifierSettingsProvider> settings_provider_;
76 std::unique_ptr<NotifierSettingsView> notifier_settings_view_; 77 std::unique_ptr<NotifierSettingsView> notifier_settings_view_;
77 78
78 DISALLOW_COPY_AND_ASSIGN(NotifierSettingsViewTest); 79 DISALLOW_COPY_AND_ASSIGN(NotifierSettingsViewTest);
79 }; 80 };
80 81
81 NotifierSettingsViewTest::NotifierSettingsViewTest() {} 82 NotifierSettingsViewTest::NotifierSettingsViewTest() {}
82 83
83 NotifierSettingsViewTest::~NotifierSettingsViewTest() {} 84 NotifierSettingsViewTest::~NotifierSettingsViewTest() {}
84 85
85 void NotifierSettingsViewTest::SetUp() { 86 void NotifierSettingsViewTest::SetUp() {
87 views::ViewsTestBase::SetUp();
86 std::vector<Notifier*> notifiers; 88 std::vector<Notifier*> notifiers;
87 notifiers.push_back(NewNotifier("id", "title", /*enabled=*/true)); 89 notifiers.push_back(NewNotifier("id", "title", /*enabled=*/true));
88 notifiers.push_back(NewNotifier("id2", "other title", /*enabled=*/false)); 90 notifiers.push_back(NewNotifier("id2", "other title", /*enabled=*/false));
89 settings_provider_.reset(new TestingNotifierSettingsProvider( 91 settings_provider_.reset(new TestingNotifierSettingsProvider(
90 notifiers, NotifierId(NotifierId::APPLICATION, "id"))); 92 notifiers, NotifierId(NotifierId::APPLICATION, "id")));
91 notifier_settings_view_.reset( 93 notifier_settings_view_.reset(
92 new NotifierSettingsView(settings_provider_.get())); 94 new NotifierSettingsView(settings_provider_.get()));
93 } 95 }
94 96
95 void NotifierSettingsViewTest::TearDown() { 97 void NotifierSettingsViewTest::TearDown() {
96 notifier_settings_view_.reset(); 98 notifier_settings_view_.reset();
97 settings_provider_.reset(); 99 settings_provider_.reset();
100 views::ViewsTestBase::TearDown();
98 } 101 }
99 102
100 NotifierSettingsView* NotifierSettingsViewTest::GetView() const { 103 NotifierSettingsView* NotifierSettingsViewTest::GetView() const {
101 return notifier_settings_view_.get(); 104 return notifier_settings_view_.get();
102 } 105 }
103 106
104 TEST_F(NotifierSettingsViewTest, TestLearnMoreButton) { 107 TEST_F(NotifierSettingsViewTest, TestLearnMoreButton) {
105 const std::set<NotifierSettingsView::NotifierButton*> buttons = 108 const std::set<NotifierSettingsView::NotifierButton*> buttons =
106 GetView()->buttons_; 109 GetView()->buttons_;
107 EXPECT_EQ(2u, buttons.size()); 110 EXPECT_EQ(2u, buttons.size());
(...skipping 10 matching lines...) Expand all
118 EXPECT_EQ(1u, number_of_settings_buttons); 121 EXPECT_EQ(1u, number_of_settings_buttons);
119 EXPECT_EQ(1u, settings_provider()->request_count()); 122 EXPECT_EQ(1u, settings_provider()->request_count());
120 const NotifierId* last_settings_button_id = 123 const NotifierId* last_settings_button_id =
121 settings_provider()->last_requested_notifier_id(); 124 settings_provider()->last_requested_notifier_id();
122 ASSERT_FALSE(last_settings_button_id == NULL); 125 ASSERT_FALSE(last_settings_button_id == NULL);
123 EXPECT_EQ(NotifierId(NotifierId::APPLICATION, "id"), 126 EXPECT_EQ(NotifierId(NotifierId::APPLICATION, "id"),
124 *last_settings_button_id); 127 *last_settings_button_id);
125 } 128 }
126 129
127 } // namespace message_center 130 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/message_center/views/message_center_view_unittest.cc ('k') | ui/shell_dialogs/run_all_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698