| 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.h" | 5 #include "base/message_loop.h" |
| 6 #include "base/synchronization/waitable_event.h" | 6 #include "base/synchronization/waitable_event.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.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 "content/public/test/test_browser_thread.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 13 |
| 13 namespace chrome { | 14 namespace chrome { |
| 14 | 15 |
| 15 TEST(StorageMonitorTest, TestInitialize) { | 16 TEST(StorageMonitorTest, TestInitialize) { |
| 17 MessageLoopForUI message_loop_; |
| 18 content::TestBrowserThread(content::BrowserThread::UI, &message_loop_); |
| 16 test::TestStorageMonitor monitor; | 19 test::TestStorageMonitor monitor; |
| 17 EXPECT_FALSE(monitor.init_called_); | 20 EXPECT_FALSE(monitor.init_called_); |
| 18 | 21 |
| 19 base::WaitableEvent event(false, false); | 22 base::WaitableEvent event(false, false); |
| 20 monitor.Initialize(base::Bind(&base::WaitableEvent::Signal, | 23 monitor.Initialize(base::Bind(&base::WaitableEvent::Signal, |
| 21 base::Unretained(&event))); | 24 base::Unretained(&event))); |
| 22 EXPECT_TRUE(monitor.init_called_); | 25 EXPECT_TRUE(monitor.init_called_); |
| 23 EXPECT_FALSE(event.IsSignaled()); | 26 EXPECT_FALSE(event.IsSignaled()); |
| 24 monitor.MarkInitialized(); | 27 monitor.MarkInitialized(); |
| 25 EXPECT_TRUE(event.IsSignaled()); | 28 EXPECT_TRUE(event.IsSignaled()); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 EXPECT_EQ(kDeviceName2, devices[0].name); | 122 EXPECT_EQ(kDeviceName2, devices[0].name); |
| 120 EXPECT_EQ(kDevicePath2.value(), devices[0].location); | 123 EXPECT_EQ(kDevicePath2.value(), devices[0].location); |
| 121 | 124 |
| 122 monitor.receiver()->ProcessDetach(kDeviceId2); | 125 monitor.receiver()->ProcessDetach(kDeviceId2); |
| 123 message_loop.RunUntilIdle(); | 126 message_loop.RunUntilIdle(); |
| 124 devices = monitor.GetAttachedStorage(); | 127 devices = monitor.GetAttachedStorage(); |
| 125 EXPECT_EQ(0U, devices.size()); | 128 EXPECT_EQ(0U, devices.size()); |
| 126 } | 129 } |
| 127 | 130 |
| 128 } // namespace chrome | 131 } // namespace chrome |
| OLD | NEW |