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 // MediaTransferProtocolDeviceObserverLinux unit tests. | 5 // MediaTransferProtocolDeviceObserverLinux unit tests. |
6 | 6 |
7 #include "components/storage_monitor/media_transfer_protocol_device_observer_lin
ux.h" | 7 #include "components/storage_monitor/media_transfer_protocol_device_observer_lin
ux.h" |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 89 |
90 } // namespace | 90 } // namespace |
91 | 91 |
92 // A class to test the functionality of MediaTransferProtocolDeviceObserverLinux | 92 // A class to test the functionality of MediaTransferProtocolDeviceObserverLinux |
93 // member functions. | 93 // member functions. |
94 class MediaTransferProtocolDeviceObserverLinuxTest : public testing::Test { | 94 class MediaTransferProtocolDeviceObserverLinuxTest : public testing::Test { |
95 public: | 95 public: |
96 MediaTransferProtocolDeviceObserverLinuxTest() | 96 MediaTransferProtocolDeviceObserverLinuxTest() |
97 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {} | 97 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {} |
98 | 98 |
99 virtual ~MediaTransferProtocolDeviceObserverLinuxTest() {} | 99 ~MediaTransferProtocolDeviceObserverLinuxTest() override {} |
100 | 100 |
101 protected: | 101 protected: |
102 virtual void SetUp() override { | 102 void SetUp() override { |
103 mock_storage_observer_.reset(new MockRemovableStorageObserver); | 103 mock_storage_observer_.reset(new MockRemovableStorageObserver); |
104 TestStorageMonitor* monitor = TestStorageMonitor::CreateAndInstall(); | 104 TestStorageMonitor* monitor = TestStorageMonitor::CreateAndInstall(); |
105 mtp_device_observer_.reset( | 105 mtp_device_observer_.reset( |
106 new TestMediaTransferProtocolDeviceObserverLinux( | 106 new TestMediaTransferProtocolDeviceObserverLinux( |
107 monitor->receiver(), monitor->media_transfer_protocol_manager())); | 107 monitor->receiver(), monitor->media_transfer_protocol_manager())); |
108 monitor->AddObserver(mock_storage_observer_.get()); | 108 monitor->AddObserver(mock_storage_observer_.get()); |
109 } | 109 } |
110 | 110 |
111 virtual void TearDown() override { | 111 void TearDown() override { |
112 StorageMonitor* monitor = StorageMonitor::GetInstance(); | 112 StorageMonitor* monitor = StorageMonitor::GetInstance(); |
113 monitor->RemoveObserver(mock_storage_observer_.get()); | 113 monitor->RemoveObserver(mock_storage_observer_.get()); |
114 mtp_device_observer_.reset(); | 114 mtp_device_observer_.reset(); |
115 TestStorageMonitor::Destroy(); | 115 TestStorageMonitor::Destroy(); |
116 } | 116 } |
117 | 117 |
118 // Returns the device changed observer object. | 118 // Returns the device changed observer object. |
119 MockRemovableStorageObserver& observer() { | 119 MockRemovableStorageObserver& observer() { |
120 return *mock_storage_observer_; | 120 return *mock_storage_observer_; |
121 } | 121 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 mtp_device_observer()->MtpStorageAttached(kStorageWithInvalidInfo); | 165 mtp_device_observer()->MtpStorageAttached(kStorageWithInvalidInfo); |
166 | 166 |
167 // Detach the attached storage. | 167 // Detach the attached storage. |
168 mtp_device_observer()->MtpStorageDetached(kStorageWithInvalidInfo); | 168 mtp_device_observer()->MtpStorageDetached(kStorageWithInvalidInfo); |
169 | 169 |
170 EXPECT_EQ(0, observer().attach_calls()); | 170 EXPECT_EQ(0, observer().attach_calls()); |
171 EXPECT_EQ(0, observer().detach_calls()); | 171 EXPECT_EQ(0, observer().detach_calls()); |
172 } | 172 } |
173 | 173 |
174 } // namespace storage_monitor | 174 } // namespace storage_monitor |
OLD | NEW |