| 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 #include "base/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "base/synchronization/waitable_event.h" | 7 #include "base/synchronization/waitable_event.h" |
| 8 #include "chrome/browser/storage_monitor/mock_removable_storage_observer.h" | 8 #include "chrome/browser/storage_monitor/mock_removable_storage_observer.h" |
| 9 #include "chrome/browser/storage_monitor/storage_monitor.h" | 9 #include "chrome/browser/storage_monitor/storage_monitor.h" |
| 10 #include "chrome/browser/storage_monitor/test_storage_monitor.h" | 10 #include "chrome/browser/storage_monitor/test_storage_monitor.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 void SetLatch(bool* called) { | 15 void SetLatch(bool* called) { |
| 16 *called = true; | 16 *called = true; |
| 17 } | 17 } |
| 18 | 18 |
| 19 } // namespace | 19 } // namespace |
| 20 | 20 |
| 21 namespace chrome { | 21 namespace chrome { |
| 22 | 22 |
| 23 TEST(StorageMonitorTest, TestInitialize) { | 23 TEST(StorageMonitorTest, TestInitialize) { |
| 24 test::TestStorageMonitor::RemoveSingleton(); | 24 test::TestStorageMonitor::RemoveSingleton(); |
| 25 test::TestStorageMonitor monitor; | 25 test::TestStorageMonitor monitor; |
| 26 EXPECT_FALSE(monitor.init_called_); | 26 EXPECT_FALSE(monitor.init_called()); |
| 27 | 27 |
| 28 bool initialized = false; | 28 bool initialized = false; |
| 29 monitor.EnsureInitialized(base::Bind(&SetLatch, &initialized)); | 29 monitor.EnsureInitialized(base::Bind(&SetLatch, &initialized)); |
| 30 EXPECT_TRUE(monitor.init_called_); | 30 EXPECT_TRUE(monitor.init_called()); |
| 31 EXPECT_FALSE(initialized); | 31 EXPECT_FALSE(initialized); |
| 32 monitor.MarkInitialized(); | 32 monitor.MarkInitialized(); |
| 33 EXPECT_TRUE(initialized); | 33 EXPECT_TRUE(initialized); |
| 34 } | 34 } |
| 35 | 35 |
| 36 TEST(StorageMonitorTest, DeviceAttachDetachNotifications) { | 36 TEST(StorageMonitorTest, DeviceAttachDetachNotifications) { |
| 37 test::TestStorageMonitor::RemoveSingleton(); | 37 test::TestStorageMonitor::RemoveSingleton(); |
| 38 base::MessageLoop message_loop; | 38 base::MessageLoop message_loop; |
| 39 const string16 kDeviceName = ASCIIToUTF16("media device"); | 39 const string16 kDeviceName = ASCIIToUTF16("media device"); |
| 40 const std::string kDeviceId1 = "dcim:UUID:FFF0-0001"; | 40 const std::string kDeviceId1 = "dcim:UUID:FFF0-0001"; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 EXPECT_EQ(kDeviceName2, devices[0].name()); | 130 EXPECT_EQ(kDeviceName2, devices[0].name()); |
| 131 EXPECT_EQ(kDevicePath2.value(), devices[0].location()); | 131 EXPECT_EQ(kDevicePath2.value(), devices[0].location()); |
| 132 | 132 |
| 133 monitor.receiver()->ProcessDetach(kDeviceId2); | 133 monitor.receiver()->ProcessDetach(kDeviceId2); |
| 134 message_loop.RunUntilIdle(); | 134 message_loop.RunUntilIdle(); |
| 135 devices = monitor.GetAllAvailableStorages(); | 135 devices = monitor.GetAllAvailableStorages(); |
| 136 EXPECT_EQ(0U, devices.size()); | 136 EXPECT_EQ(0U, devices.size()); |
| 137 } | 137 } |
| 138 | 138 |
| 139 } // namespace chrome | 139 } // namespace chrome |
| OLD | NEW |