| OLD | NEW |
| 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 <memory> | 5 #include <memory> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "components/arc/instance_holder.h" | 12 #include "components/arc/instance_holder.h" |
| 13 #include "components/arc/test/fake_arc_bridge_instance.h" | 13 #include "components/arc/test/fake_arc_bridge_instance.h" |
| 14 #include "components/arc/test/fake_arc_bridge_service.h" | 14 #include "components/arc/test/fake_arc_bridge_service.h" |
| 15 #include "components/arc/test/fake_notifications_instance.h" | 15 #include "components/arc/test/fake_notifications_instance.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "ui/arc/notification/arc_notification_manager.h" | 17 #include "ui/arc/notification/arc_notification_manager.h" |
| 18 #include "ui/message_center/fake_message_center.h" | 18 #include "ui/message_center/fake_message_center.h" |
| 19 | 19 |
| 20 namespace arc { | 20 namespace arc { |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 const char kDummyNotificationKey[] = "DUMMY_NOTIFICATION_KEY"; | 24 const char kDummyNotificationKey[] = "DUMMY_NOTIFICATION_KEY"; |
| 25 | 25 |
| 26 class MockMessageCenter : public message_center::FakeMessageCenter { | 26 class MockMessageCenter : public message_center::FakeMessageCenter { |
| 27 public: | 27 public: |
| 28 MockMessageCenter() {} | 28 MockMessageCenter() {} |
| 29 ~MockMessageCenter() override { | 29 ~MockMessageCenter() override { |
| 30 STLDeleteContainerPointers( | 30 base::STLDeleteContainerPointers(visible_notifications_.begin(), |
| 31 visible_notifications_.begin(), visible_notifications_.end()); | 31 visible_notifications_.end()); |
| 32 } | 32 } |
| 33 | 33 |
| 34 void AddNotification( | 34 void AddNotification( |
| 35 std::unique_ptr<message_center::Notification> notification) override { | 35 std::unique_ptr<message_center::Notification> notification) override { |
| 36 visible_notifications_.insert(notification.release()); | 36 visible_notifications_.insert(notification.release()); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void RemoveNotification(const std::string& id, bool by_user) override { | 39 void RemoveNotification(const std::string& id, bool by_user) override { |
| 40 for (auto it = visible_notifications_.begin(); | 40 for (auto it = visible_notifications_.begin(); |
| 41 it != visible_notifications_.end(); it++) { | 41 it != visible_notifications_.end(); it++) { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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()->OnInstanceClosed(); | 182 arc_notification_manager()->OnInstanceClosed(); |
| 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 |
| OLD | NEW |