OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #import "chrome/browser/ui/cocoa/notifications/message_center_tray_bridge.h" | 5 #import "chrome/browser/ui/cocoa/notifications/message_center_tray_bridge.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
13 #include "chrome/test/base/testing_browser_process.h" | 13 #include "chrome/test/base/testing_browser_process.h" |
14 #include "chrome/test/base/scoped_testing_local_state.h" | 14 #include "chrome/test/base/scoped_testing_local_state.h" |
15 #import "ui/gfx/test/ui_cocoa_test_helper.h" | 15 #import "ui/gfx/test/ui_cocoa_test_helper.h" |
16 #import "ui/message_center/cocoa/status_item_view.h" | 16 #import "ui/message_center/cocoa/status_item_view.h" |
17 #include "ui/message_center/message_center.h" | 17 #include "ui/message_center/message_center.h" |
18 #include "ui/message_center/notification.h" | 18 #include "ui/message_center/notification.h" |
19 #include "ui/message_center/notifier_settings.h" | 19 #include "ui/message_center/notifier_settings.h" |
20 | 20 |
21 class MessageCenterTrayBridgeTest : public ui::CocoaTest { | 21 class MessageCenterTrayBridgeTest : public ui::CocoaTest { |
22 public: | 22 public: |
23 virtual void SetUp() OVERRIDE { | 23 virtual void SetUp() override { |
24 ui::CocoaTest::SetUp(); | 24 ui::CocoaTest::SetUp(); |
25 | 25 |
26 local_state_.reset( | 26 local_state_.reset( |
27 new ScopedTestingLocalState(TestingBrowserProcess::GetGlobal())); | 27 new ScopedTestingLocalState(TestingBrowserProcess::GetGlobal())); |
28 message_center::MessageCenter::Initialize(); | 28 message_center::MessageCenter::Initialize(); |
29 center_ = message_center::MessageCenter::Get(); | 29 center_ = message_center::MessageCenter::Get(); |
30 | 30 |
31 bridge_.reset(new MessageCenterTrayBridge(center_)); | 31 bridge_.reset(new MessageCenterTrayBridge(center_)); |
32 } | 32 } |
33 | 33 |
34 virtual void TearDown() OVERRIDE { | 34 virtual void TearDown() override { |
35 bridge_.reset(); | 35 bridge_.reset(); |
36 message_center::MessageCenter::Shutdown(); | 36 message_center::MessageCenter::Shutdown(); |
37 local_state_.reset(); | 37 local_state_.reset(); |
38 initializer_.reset(); | 38 initializer_.reset(); |
39 ui::CocoaTest::TearDown(); | 39 ui::CocoaTest::TearDown(); |
40 } | 40 } |
41 | 41 |
42 MCStatusItemView* status_item() { return bridge_->status_item_view_.get(); } | 42 MCStatusItemView* status_item() { return bridge_->status_item_view_.get(); } |
43 | 43 |
44 protected: | 44 protected: |
(...skipping 18 matching lines...) Expand all Loading... |
63 scoped_ptr<ScopedTestingLocalState> local_state_; | 63 scoped_ptr<ScopedTestingLocalState> local_state_; |
64 | 64 |
65 base::MessageLoop message_loop_; | 65 base::MessageLoop message_loop_; |
66 message_center::MessageCenter* center_; // Weak, global. | 66 message_center::MessageCenter* center_; // Weak, global. |
67 scoped_ptr<MessageCenterTrayBridge> bridge_; | 67 scoped_ptr<MessageCenterTrayBridge> bridge_; |
68 }; | 68 }; |
69 | 69 |
70 class MessageCenterTrayBridgeTestPrefNever | 70 class MessageCenterTrayBridgeTestPrefNever |
71 : public MessageCenterTrayBridgeTest { | 71 : public MessageCenterTrayBridgeTest { |
72 public: | 72 public: |
73 virtual void SetUp() OVERRIDE { | 73 virtual void SetUp() override { |
74 MessageCenterTrayBridgeTest::SetUp(); | 74 MessageCenterTrayBridgeTest::SetUp(); |
75 local_state()->SetBoolean(prefs::kMessageCenterShowIcon, false); | 75 local_state()->SetBoolean(prefs::kMessageCenterShowIcon, false); |
76 } | 76 } |
77 }; | 77 }; |
78 | 78 |
79 TEST_F(MessageCenterTrayBridgeTest, StatusItemOnlyAfterFirstNotification) { | 79 TEST_F(MessageCenterTrayBridgeTest, StatusItemOnlyAfterFirstNotification) { |
80 EXPECT_FALSE(status_item()); | 80 EXPECT_FALSE(status_item()); |
81 | 81 |
82 center_->AddNotification(GetNotification()); | 82 center_->AddNotification(GetNotification()); |
83 | 83 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 center_->RemoveNotification("1", /*by_user=*/true); | 142 center_->RemoveNotification("1", /*by_user=*/true); |
143 | 143 |
144 base::RunLoop().RunUntilIdle(); | 144 base::RunLoop().RunUntilIdle(); |
145 | 145 |
146 EXPECT_FALSE(status_item()); | 146 EXPECT_FALSE(status_item()); |
147 | 147 |
148 local_state()->SetBoolean(prefs::kMessageCenterShowIcon, true); | 148 local_state()->SetBoolean(prefs::kMessageCenterShowIcon, true); |
149 | 149 |
150 EXPECT_TRUE(status_item()); | 150 EXPECT_TRUE(status_item()); |
151 } | 151 } |
OLD | NEW |