OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/chromeos/extensions/file_manager/device_event_router.h" | 5 #include "chrome/browser/chromeos/extensions/file_manager/device_event_router.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 // DeviceEventRouter implementation for testing. | 28 // DeviceEventRouter implementation for testing. |
29 class DeviceEventRouterImpl : public DeviceEventRouter { | 29 class DeviceEventRouterImpl : public DeviceEventRouter { |
30 public: | 30 public: |
31 DeviceEventRouterImpl() | 31 DeviceEventRouterImpl() |
32 : DeviceEventRouter(base::TimeDelta::FromSeconds(0)), | 32 : DeviceEventRouter(base::TimeDelta::FromSeconds(0)), |
33 external_storage_disabled(false) {} | 33 external_storage_disabled(false) {} |
34 virtual ~DeviceEventRouterImpl() {} | 34 virtual ~DeviceEventRouterImpl() {} |
35 | 35 |
36 // DeviceEventRouter overrides. | 36 // DeviceEventRouter overrides. |
37 virtual void OnDeviceEvent(file_manager_private::DeviceEventType type, | 37 virtual void OnDeviceEvent(file_manager_private::DeviceEventType type, |
38 const std::string& device_path) OVERRIDE { | 38 const std::string& device_path) override { |
39 DeviceEvent event; | 39 DeviceEvent event; |
40 event.type = type; | 40 event.type = type; |
41 event.device_path = device_path; | 41 event.device_path = device_path; |
42 events.push_back(event); | 42 events.push_back(event); |
43 } | 43 } |
44 | 44 |
45 // DeviceEventRouter overrides. | 45 // DeviceEventRouter overrides. |
46 virtual bool IsExternalStorageDisabled() OVERRIDE { | 46 virtual bool IsExternalStorageDisabled() override { |
47 return external_storage_disabled; | 47 return external_storage_disabled; |
48 } | 48 } |
49 | 49 |
50 // List of dispatched events. | 50 // List of dispatched events. |
51 std::vector<DeviceEvent> events; | 51 std::vector<DeviceEvent> events; |
52 | 52 |
53 // Flag returned by |IsExternalStorageDisabled|. | 53 // Flag returned by |IsExternalStorageDisabled|. |
54 bool external_storage_disabled; | 54 bool external_storage_disabled; |
55 | 55 |
56 private: | 56 private: |
57 DISALLOW_COPY_AND_ASSIGN(DeviceEventRouterImpl); | 57 DISALLOW_COPY_AND_ASSIGN(DeviceEventRouterImpl); |
58 }; | 58 }; |
59 | 59 |
60 } // namespace | 60 } // namespace |
61 | 61 |
62 class DeviceEventRouterTest : public testing::Test { | 62 class DeviceEventRouterTest : public testing::Test { |
63 protected: | 63 protected: |
64 virtual void SetUp() OVERRIDE { | 64 virtual void SetUp() override { |
65 device_event_router.reset(new DeviceEventRouterImpl()); | 65 device_event_router.reset(new DeviceEventRouterImpl()); |
66 } | 66 } |
67 | 67 |
68 // Creates a disk instance with |device_path| and |mount_path| for testing. | 68 // Creates a disk instance with |device_path| and |mount_path| for testing. |
69 Disk CreateTestDisk(const std::string& device_path, | 69 Disk CreateTestDisk(const std::string& device_path, |
70 const std::string& mount_path) { | 70 const std::string& mount_path) { |
71 return Disk(device_path, | 71 return Disk(device_path, |
72 mount_path, | 72 mount_path, |
73 "", | 73 "", |
74 "", | 74 "", |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 ASSERT_EQ(2u, device_event_router->events.size()); | 137 ASSERT_EQ(2u, device_event_router->events.size()); |
138 EXPECT_EQ(file_manager_private::DEVICE_EVENT_TYPE_HARD_UNPLUGGED, | 138 EXPECT_EQ(file_manager_private::DEVICE_EVENT_TYPE_HARD_UNPLUGGED, |
139 device_event_router->events[0].type); | 139 device_event_router->events[0].type); |
140 EXPECT_EQ("/device/test", device_event_router->events[0].device_path); | 140 EXPECT_EQ("/device/test", device_event_router->events[0].device_path); |
141 EXPECT_EQ(file_manager_private::DEVICE_EVENT_TYPE_REMOVED, | 141 EXPECT_EQ(file_manager_private::DEVICE_EVENT_TYPE_REMOVED, |
142 device_event_router->events[1].type); | 142 device_event_router->events[1].type); |
143 EXPECT_EQ("/device/test", device_event_router->events[1].device_path); | 143 EXPECT_EQ("/device/test", device_event_router->events[1].device_path); |
144 } | 144 } |
145 | 145 |
146 } // namespace file_manager | 146 } // namespace file_manager |
OLD | NEW |