| 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 "chrome/browser/system_monitor/media_device_notifications_utils.h" | 5 #include "chrome/browser/system_monitor/media_device_notifications_utils.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 10 #include "base/scoped_temp_dir.h" | |
| 11 #include "chrome/browser/system_monitor/removable_device_constants.h" | 11 #include "chrome/browser/system_monitor/removable_device_constants.h" |
| 12 #include "content/public/test/test_browser_thread.h" | 12 #include "content/public/test/test_browser_thread.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 namespace chrome { | 15 namespace chrome { |
| 16 | 16 |
| 17 using content::BrowserThread; | 17 using content::BrowserThread; |
| 18 | 18 |
| 19 class MediaDeviceNotificationUtilsTest : public testing::Test { | 19 class MediaDeviceNotificationUtilsTest : public testing::Test { |
| 20 public: | 20 public: |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 FROM_HERE, | 63 FROM_HERE, |
| 64 base::Bind(&PostQuitToUIThread)); | 64 base::Bind(&PostQuitToUIThread)); |
| 65 MessageLoop::current()->Run(); | 65 MessageLoop::current()->Run(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 MessageLoop message_loop_; | 68 MessageLoop message_loop_; |
| 69 | 69 |
| 70 private: | 70 private: |
| 71 content::TestBrowserThread ui_thread_; | 71 content::TestBrowserThread ui_thread_; |
| 72 content::TestBrowserThread file_thread_; | 72 content::TestBrowserThread file_thread_; |
| 73 ScopedTempDir scoped_temp_dir_; | 73 base::ScopedTempDir scoped_temp_dir_; |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 // Test to verify that IsMediaDevice() function returns true for the given | 76 // Test to verify that IsMediaDevice() function returns true for the given |
| 77 // media device mount point. | 77 // media device mount point. |
| 78 TEST_F(MediaDeviceNotificationUtilsTest, MediaDeviceAttached) { | 78 TEST_F(MediaDeviceNotificationUtilsTest, MediaDeviceAttached) { |
| 79 // Create a dummy mount point with DCIM Directory. | 79 // Create a dummy mount point with DCIM Directory. |
| 80 FilePath mount_point(CreateMountPoint(true)); | 80 FilePath mount_point(CreateMountPoint(true)); |
| 81 BrowserThread::PostTask( | 81 BrowserThread::PostTask( |
| 82 BrowserThread::FILE, FROM_HERE, | 82 BrowserThread::FILE, FROM_HERE, |
| 83 base::Bind(&MediaDeviceNotificationUtilsTest::checkDeviceType, | 83 base::Bind(&MediaDeviceNotificationUtilsTest::checkDeviceType, |
| 84 base::Unretained(this), mount_point.value(), true)); | 84 base::Unretained(this), mount_point.value(), true)); |
| 85 message_loop_.RunAllPending(); | 85 message_loop_.RunAllPending(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 // Test to verify that IsMediaDevice() function returns false for a given | 88 // Test to verify that IsMediaDevice() function returns false for a given |
| 89 // non-media device mount point. | 89 // non-media device mount point. |
| 90 TEST_F(MediaDeviceNotificationUtilsTest, NonMediaDeviceAttached) { | 90 TEST_F(MediaDeviceNotificationUtilsTest, NonMediaDeviceAttached) { |
| 91 // Create a dummy mount point without DCIM Directory. | 91 // Create a dummy mount point without DCIM Directory. |
| 92 FilePath mount_point(CreateMountPoint(false)); | 92 FilePath mount_point(CreateMountPoint(false)); |
| 93 BrowserThread::PostTask( | 93 BrowserThread::PostTask( |
| 94 BrowserThread::FILE, FROM_HERE, | 94 BrowserThread::FILE, FROM_HERE, |
| 95 base::Bind(&MediaDeviceNotificationUtilsTest::checkDeviceType, | 95 base::Bind(&MediaDeviceNotificationUtilsTest::checkDeviceType, |
| 96 base::Unretained(this), mount_point.value(), false)); | 96 base::Unretained(this), mount_point.value(), false)); |
| 97 message_loop_.RunAllPending(); | 97 message_loop_.RunAllPending(); |
| 98 } | 98 } |
| 99 | 99 |
| 100 } // namespace chrome | 100 } // namespace chrome |
| OLD | NEW |