OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/storage_monitor/media_transfer_protocol_device_observer
_linux.h" | 7 #include "chrome/browser/storage_monitor/media_transfer_protocol_device_observer
_linux.h" |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 DISALLOW_COPY_AND_ASSIGN(TestMediaTransferProtocolDeviceObserverLinux); | 77 DISALLOW_COPY_AND_ASSIGN(TestMediaTransferProtocolDeviceObserverLinux); |
78 }; | 78 }; |
79 | 79 |
80 } // namespace | 80 } // namespace |
81 | 81 |
82 // A class to test the functionality of MediaTransferProtocolDeviceObserverLinux | 82 // A class to test the functionality of MediaTransferProtocolDeviceObserverLinux |
83 // member functions. | 83 // member functions. |
84 class MediaTransferProtocolDeviceObserverLinuxTest : public testing::Test { | 84 class MediaTransferProtocolDeviceObserverLinuxTest : public testing::Test { |
85 public: | 85 public: |
86 MediaTransferProtocolDeviceObserverLinuxTest() | 86 MediaTransferProtocolDeviceObserverLinuxTest() |
87 : message_loop_(MessageLoop::TYPE_IO), | 87 : message_loop_(base::MessageLoop::TYPE_IO), |
88 file_thread_(content::BrowserThread::FILE, &message_loop_) {} | 88 file_thread_(content::BrowserThread::FILE, &message_loop_) {} |
89 | 89 |
90 virtual ~MediaTransferProtocolDeviceObserverLinuxTest() {} | 90 virtual ~MediaTransferProtocolDeviceObserverLinuxTest() {} |
91 | 91 |
92 protected: | 92 protected: |
93 virtual void SetUp() OVERRIDE { | 93 virtual void SetUp() OVERRIDE { |
94 mock_storage_observer_.reset(new MockRemovableStorageObserver); | 94 mock_storage_observer_.reset(new MockRemovableStorageObserver); |
95 mtp_device_observer_.reset( | 95 mtp_device_observer_.reset( |
96 new TestMediaTransferProtocolDeviceObserverLinux(monitor_.receiver())); | 96 new TestMediaTransferProtocolDeviceObserverLinux(monitor_.receiver())); |
97 monitor_.AddObserver(mock_storage_observer_.get()); | 97 monitor_.AddObserver(mock_storage_observer_.get()); |
98 } | 98 } |
99 | 99 |
100 virtual void TearDown() OVERRIDE { | 100 virtual void TearDown() OVERRIDE { |
101 monitor_.RemoveObserver(mock_storage_observer_.get()); | 101 monitor_.RemoveObserver(mock_storage_observer_.get()); |
102 mtp_device_observer_.reset(); | 102 mtp_device_observer_.reset(); |
103 } | 103 } |
104 | 104 |
105 // Returns the device changed observer object. | 105 // Returns the device changed observer object. |
106 MockRemovableStorageObserver& observer() { | 106 MockRemovableStorageObserver& observer() { |
107 return *mock_storage_observer_; | 107 return *mock_storage_observer_; |
108 } | 108 } |
109 | 109 |
110 TestMediaTransferProtocolDeviceObserverLinux* mtp_device_observer() { | 110 TestMediaTransferProtocolDeviceObserverLinux* mtp_device_observer() { |
111 return mtp_device_observer_.get(); | 111 return mtp_device_observer_.get(); |
112 } | 112 } |
113 | 113 |
114 private: | 114 private: |
115 MessageLoop message_loop_; | 115 base::MessageLoop message_loop_; |
116 content::TestBrowserThread file_thread_; | 116 content::TestBrowserThread file_thread_; |
117 | 117 |
118 chrome::test::TestStorageMonitor monitor_; | 118 chrome::test::TestStorageMonitor monitor_; |
119 scoped_ptr<TestMediaTransferProtocolDeviceObserverLinux> mtp_device_observer_; | 119 scoped_ptr<TestMediaTransferProtocolDeviceObserverLinux> mtp_device_observer_; |
120 scoped_ptr<MockRemovableStorageObserver> mock_storage_observer_; | 120 scoped_ptr<MockRemovableStorageObserver> mock_storage_observer_; |
121 | 121 |
122 DISALLOW_COPY_AND_ASSIGN(MediaTransferProtocolDeviceObserverLinuxTest); | 122 DISALLOW_COPY_AND_ASSIGN(MediaTransferProtocolDeviceObserverLinuxTest); |
123 }; | 123 }; |
124 | 124 |
125 // Test to verify basic mtp storage attach and detach notifications. | 125 // Test to verify basic mtp storage attach and detach notifications. |
(...skipping 25 matching lines...) Expand all Loading... |
151 mtp_device_observer()->MtpStorageAttached(kStorageWithInvalidInfo); | 151 mtp_device_observer()->MtpStorageAttached(kStorageWithInvalidInfo); |
152 | 152 |
153 // Detach the attached storage. | 153 // Detach the attached storage. |
154 mtp_device_observer()->MtpStorageDetached(kStorageWithInvalidInfo); | 154 mtp_device_observer()->MtpStorageDetached(kStorageWithInvalidInfo); |
155 | 155 |
156 EXPECT_EQ(0, observer().attach_calls()); | 156 EXPECT_EQ(0, observer().attach_calls()); |
157 EXPECT_EQ(0, observer().detach_calls()); | 157 EXPECT_EQ(0, observer().detach_calls()); |
158 } | 158 } |
159 | 159 |
160 } // namespace chrome | 160 } // namespace chrome |
OLD | NEW |