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

Side by Side Diff: ui/arc/notification/arc_notification_manager_unittest.cc

Issue 1885683005: Add module suffix in .mojom files for components/arc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase only 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
« no previous file with comments | « ui/arc/notification/arc_notification_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/message_loop/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "components/arc/test/fake_arc_bridge_instance.h" 7 #include "components/arc/test/fake_arc_bridge_instance.h"
8 #include "components/arc/test/fake_arc_bridge_service.h" 8 #include "components/arc/test/fake_arc_bridge_service.h"
9 #include "components/arc/test/fake_notifications_instance.h" 9 #include "components/arc/test/fake_notifications_instance.h"
10 #include "mojo/message_pump/message_pump_mojo.h" 10 #include "mojo/message_pump/message_pump_mojo.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 ArcNotificationManager* arc_notification_manager() { 82 ArcNotificationManager* arc_notification_manager() {
83 return arc_notification_manager_.get(); 83 return arc_notification_manager_.get();
84 } 84 }
85 MockMessageCenter* message_center() { return message_center_.get(); } 85 MockMessageCenter* message_center() { return message_center_.get(); }
86 86
87 std::string CreateNotification() { 87 std::string CreateNotification() {
88 return CreateNotificationWithKey(kDummyNotificationKey); 88 return CreateNotificationWithKey(kDummyNotificationKey);
89 } 89 }
90 90
91 std::string CreateNotificationWithKey(const std::string& key) { 91 std::string CreateNotificationWithKey(const std::string& key) {
92 auto data = ArcNotificationData::New(); 92 auto data = mojom::ArcNotificationData::New();
93 data->key = key; 93 data->key = key;
94 data->title = "TITLE"; 94 data->title = "TITLE";
95 data->message = "MESSAGE"; 95 data->message = "MESSAGE";
96 96
97 std::vector<unsigned char> icon_data; 97 std::vector<unsigned char> icon_data;
98 data->icon_data.Swap(&icon_data); 98 data->icon_data.Swap(&icon_data);
99 99
100 arc_notification_manager()->OnNotificationPosted(std::move(data)); 100 arc_notification_manager()->OnNotificationPosted(std::move(data));
101 101
102 return key; 102 return key;
103 } 103 }
104 104
105 private: 105 private:
106 base::MessageLoop loop_; 106 base::MessageLoop loop_;
107 std::unique_ptr<FakeArcBridgeService> service_; 107 std::unique_ptr<FakeArcBridgeService> service_;
108 std::unique_ptr<FakeNotificationsInstance> arc_notifications_instance_; 108 std::unique_ptr<FakeNotificationsInstance> arc_notifications_instance_;
109 std::unique_ptr<ArcNotificationManager> arc_notification_manager_; 109 std::unique_ptr<ArcNotificationManager> arc_notification_manager_;
110 std::unique_ptr<MockMessageCenter> message_center_; 110 std::unique_ptr<MockMessageCenter> message_center_;
111 111
112 void SetUp() override { 112 void SetUp() override {
113 NotificationsInstancePtr arc_notifications_instance; 113 mojom::NotificationsInstancePtr arc_notifications_instance;
114 arc_notifications_instance_.reset( 114 arc_notifications_instance_.reset(
115 new FakeNotificationsInstance(GetProxy(&arc_notifications_instance))); 115 new FakeNotificationsInstance(GetProxy(&arc_notifications_instance)));
116 service_.reset(new FakeArcBridgeService()); 116 service_.reset(new FakeArcBridgeService());
117 message_center_.reset(new MockMessageCenter()); 117 message_center_.reset(new MockMessageCenter());
118 118
119 arc_notification_manager_.reset(new ArcNotificationManager( 119 arc_notification_manager_.reset(new ArcNotificationManager(
120 service(), EmptyAccountId(), message_center_.get())); 120 service(), EmptyAccountId(), message_center_.get()));
121 121
122 ArcBridgeServiceObserver observer; 122 ArcBridgeServiceObserver observer;
123 service_->AddObserver(&observer); 123 service_->AddObserver(&observer);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 message_center::Notification* notification = 160 message_center::Notification* notification =
161 *message_center()->GetVisibleNotifications().begin(); 161 *message_center()->GetVisibleNotifications().begin();
162 notification->delegate()->Close(true /* by_user */); 162 notification->delegate()->Close(true /* by_user */);
163 // |notification| gets stale here. 163 // |notification| gets stale here.
164 } 164 }
165 165
166 arc_notifications_instance()->WaitForIncomingMethodCall(); 166 arc_notifications_instance()->WaitForIncomingMethodCall();
167 167
168 ASSERT_EQ(1u, arc_notifications_instance()->events().size()); 168 ASSERT_EQ(1u, arc_notifications_instance()->events().size());
169 EXPECT_EQ(key, arc_notifications_instance()->events().at(0).first); 169 EXPECT_EQ(key, arc_notifications_instance()->events().at(0).first);
170 EXPECT_EQ(ArcNotificationEvent::CLOSED, 170 EXPECT_EQ(mojom::ArcNotificationEvent::CLOSED,
171 arc_notifications_instance()->events().at(0).second); 171 arc_notifications_instance()->events().at(0).second);
172 } 172 }
173 173
174 TEST_F(ArcNotificationManagerTest, NotificationRemovedByConnectionClose) { 174 TEST_F(ArcNotificationManagerTest, NotificationRemovedByConnectionClose) {
175 service()->SetReady(); 175 service()->SetReady();
176 EXPECT_EQ(0u, message_center()->GetVisibleNotifications().size()); 176 EXPECT_EQ(0u, message_center()->GetVisibleNotifications().size());
177 CreateNotificationWithKey("notification1"); 177 CreateNotificationWithKey("notification1");
178 CreateNotificationWithKey("notification2"); 178 CreateNotificationWithKey("notification2");
179 CreateNotificationWithKey("notification3"); 179 CreateNotificationWithKey("notification3");
180 EXPECT_EQ(3u, message_center()->GetVisibleNotifications().size()); 180 EXPECT_EQ(3u, message_center()->GetVisibleNotifications().size());
181 181
182 arc_notification_manager()->OnNotificationsInstanceClosed(); 182 arc_notification_manager()->OnNotificationsInstanceClosed();
183 183
184 EXPECT_EQ(0u, message_center()->GetVisibleNotifications().size()); 184 EXPECT_EQ(0u, message_center()->GetVisibleNotifications().size());
185 } 185 }
186 186
187 } // namespace arc 187 } // namespace arc
OLDNEW
« no previous file with comments | « ui/arc/notification/arc_notification_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698