OLD | NEW |
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 "base/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 #include "ui/message_center/fake_notifier_settings_provider.h" | 7 #include "ui/message_center/fake_notifier_settings_provider.h" |
8 #include "ui/message_center/views/notifier_settings_view.h" | 8 #include "ui/message_center/views/notifier_settings_view.h" |
9 | 9 |
10 namespace message_center { | 10 namespace message_center { |
(...skipping 13 matching lines...) Expand all Loading... |
24 : public FakeNotifierSettingsProvider { | 24 : public FakeNotifierSettingsProvider { |
25 public: | 25 public: |
26 TestingNotifierSettingsProvider(const std::vector<Notifier*>& notifiers, | 26 TestingNotifierSettingsProvider(const std::vector<Notifier*>& notifiers, |
27 const NotifierId& settings_handler_id) | 27 const NotifierId& settings_handler_id) |
28 : FakeNotifierSettingsProvider(notifiers), | 28 : FakeNotifierSettingsProvider(notifiers), |
29 settings_handler_id_(settings_handler_id), | 29 settings_handler_id_(settings_handler_id), |
30 request_count_(0u) {} | 30 request_count_(0u) {} |
31 virtual ~TestingNotifierSettingsProvider() {} | 31 virtual ~TestingNotifierSettingsProvider() {} |
32 | 32 |
33 virtual bool NotifierHasAdvancedSettings(const NotifierId& notifier_id) const | 33 virtual bool NotifierHasAdvancedSettings(const NotifierId& notifier_id) const |
34 OVERRIDE { | 34 override { |
35 return notifier_id == settings_handler_id_; | 35 return notifier_id == settings_handler_id_; |
36 } | 36 } |
37 | 37 |
38 virtual void OnNotifierAdvancedSettingsRequested( | 38 virtual void OnNotifierAdvancedSettingsRequested( |
39 const NotifierId& notifier_id, | 39 const NotifierId& notifier_id, |
40 const std::string* notification_id) OVERRIDE { | 40 const std::string* notification_id) override { |
41 request_count_++; | 41 request_count_++; |
42 last_notifier_id_settings_requested_.reset(new NotifierId(notifier_id)); | 42 last_notifier_id_settings_requested_.reset(new NotifierId(notifier_id)); |
43 } | 43 } |
44 | 44 |
45 size_t request_count() const { return request_count_; } | 45 size_t request_count() const { return request_count_; } |
46 const NotifierId* last_requested_notifier_id() const { | 46 const NotifierId* last_requested_notifier_id() const { |
47 return last_notifier_id_settings_requested_.get(); | 47 return last_notifier_id_settings_requested_.get(); |
48 } | 48 } |
49 | 49 |
50 private: | 50 private: |
51 NotifierId settings_handler_id_; | 51 NotifierId settings_handler_id_; |
52 size_t request_count_; | 52 size_t request_count_; |
53 scoped_ptr<NotifierId> last_notifier_id_settings_requested_; | 53 scoped_ptr<NotifierId> last_notifier_id_settings_requested_; |
54 }; | 54 }; |
55 | 55 |
56 } // namespace | 56 } // namespace |
57 | 57 |
58 class NotifierSettingsViewTest : public testing::Test { | 58 class NotifierSettingsViewTest : public testing::Test { |
59 public: | 59 public: |
60 NotifierSettingsViewTest(); | 60 NotifierSettingsViewTest(); |
61 virtual ~NotifierSettingsViewTest(); | 61 virtual ~NotifierSettingsViewTest(); |
62 | 62 |
63 virtual void SetUp() OVERRIDE; | 63 virtual void SetUp() override; |
64 virtual void TearDown() OVERRIDE; | 64 virtual void TearDown() override; |
65 | 65 |
66 NotifierSettingsView* GetView() const; | 66 NotifierSettingsView* GetView() const; |
67 TestingNotifierSettingsProvider* settings_provider() const { | 67 TestingNotifierSettingsProvider* settings_provider() const { |
68 return settings_provider_.get(); | 68 return settings_provider_.get(); |
69 } | 69 } |
70 | 70 |
71 private: | 71 private: |
72 scoped_ptr<TestingNotifierSettingsProvider> settings_provider_; | 72 scoped_ptr<TestingNotifierSettingsProvider> settings_provider_; |
73 scoped_ptr<NotifierSettingsView> notifier_settings_view_; | 73 scoped_ptr<NotifierSettingsView> notifier_settings_view_; |
74 | 74 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 EXPECT_EQ(1u, number_of_settings_buttons); | 115 EXPECT_EQ(1u, number_of_settings_buttons); |
116 EXPECT_EQ(1u, settings_provider()->request_count()); | 116 EXPECT_EQ(1u, settings_provider()->request_count()); |
117 const NotifierId* last_settings_button_id = | 117 const NotifierId* last_settings_button_id = |
118 settings_provider()->last_requested_notifier_id(); | 118 settings_provider()->last_requested_notifier_id(); |
119 ASSERT_FALSE(last_settings_button_id == NULL); | 119 ASSERT_FALSE(last_settings_button_id == NULL); |
120 EXPECT_EQ(NotifierId(NotifierId::APPLICATION, "id"), | 120 EXPECT_EQ(NotifierId(NotifierId::APPLICATION, "id"), |
121 *last_settings_button_id); | 121 *last_settings_button_id); |
122 } | 122 } |
123 | 123 |
124 } // namespace message_center | 124 } // namespace message_center |
OLD | NEW |