Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5963)

Unified Diff: chrome/browser/media_gallery/media_device_notifications_utils_unittest.cc

Issue 10919051: Move device notification impl out of chrome/browser/media_gallery (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: modify for chromeos and win Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/media_gallery/media_device_notifications_utils_unittest.cc
diff --git a/chrome/browser/media_gallery/media_device_notifications_utils_unittest.cc b/chrome/browser/media_gallery/media_device_notifications_utils_unittest.cc
deleted file mode 100644
index 313f5eea5e36db216174e59b63aadb66a6de1292..0000000000000000000000000000000000000000
--- a/chrome/browser/media_gallery/media_device_notifications_utils_unittest.cc
+++ /dev/null
@@ -1,109 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/media_gallery/media_device_notifications_utils.h"
-
-#include "base/file_path.h"
-#include "base/file_util.h"
-#include "base/message_loop.h"
-#include "base/scoped_temp_dir.h"
-#include "content/public/test/test_browser_thread.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace chrome {
-
-namespace {
-
-#if defined(OS_WIN)
-const wchar_t kDCIMDirName[] = L"DCIM";
-#else
-const char kDCIMDirName[] = "DCIM";
-#endif
-
-} // namespace
-
-using content::BrowserThread;
-
-class MediaDeviceNotificationUtilsTest : public testing::Test {
- public:
- MediaDeviceNotificationUtilsTest()
- : ui_thread_(BrowserThread::UI, &message_loop_),
- file_thread_(BrowserThread::FILE) { }
- virtual ~MediaDeviceNotificationUtilsTest() { }
-
- // Verify mounted device type.
- void checkDeviceType(const FilePath::StringType& mount_point,
- bool expected_val) {
- if (expected_val)
- EXPECT_TRUE(IsMediaDevice(mount_point));
- else
- EXPECT_FALSE(IsMediaDevice(mount_point));
- }
-
- protected:
- // Create mount point for the test device.
- FilePath CreateMountPoint(bool create_dcim_dir) {
- FilePath path(scoped_temp_dir_.path());
- if (create_dcim_dir)
- path = path.Append(kDCIMDirName);
- if (!file_util::CreateDirectory(path))
- return FilePath();
- return scoped_temp_dir_.path();
- }
-
- virtual void SetUp() OVERRIDE {
- ASSERT_TRUE(scoped_temp_dir_.CreateUniqueTempDir());
- file_thread_.Start();
- }
-
- virtual void TearDown() {
- WaitForFileThread();
- }
-
- static void PostQuitToUIThread() {
- BrowserThread::PostTask(BrowserThread::UI,
- FROM_HERE,
- MessageLoop::QuitClosure());
- }
-
- static void WaitForFileThread() {
- BrowserThread::PostTask(BrowserThread::FILE,
- FROM_HERE,
- base::Bind(&PostQuitToUIThread));
- MessageLoop::current()->Run();
- }
-
- MessageLoop message_loop_;
-
- private:
- content::TestBrowserThread ui_thread_;
- content::TestBrowserThread file_thread_;
- ScopedTempDir scoped_temp_dir_;
-};
-
-// Test to verify that IsMediaDevice() function returns true for the given
-// media device mount point.
-TEST_F(MediaDeviceNotificationUtilsTest, MediaDeviceAttached) {
- // Create a dummy mount point with DCIM Directory.
- FilePath mount_point(CreateMountPoint(true));
- BrowserThread::PostTask(
- BrowserThread::FILE, FROM_HERE,
- base::Bind(&MediaDeviceNotificationUtilsTest::checkDeviceType,
- base::Unretained(this), mount_point.value(), true));
- message_loop_.RunAllPending();
-}
-
-// Test to verify that IsMediaDevice() function returns false for a given
-// non-media device mount point.
-TEST_F(MediaDeviceNotificationUtilsTest, NonMediaDeviceAttached) {
- // Create a dummy mount point without DCIM Directory.
- FilePath mount_point(CreateMountPoint(false));
- BrowserThread::PostTask(
- BrowserThread::FILE, FROM_HERE,
- base::Bind(&MediaDeviceNotificationUtilsTest::checkDeviceType,
- base::Unretained(this), mount_point.value(), false));
- message_loop_.RunAllPending();
-}
-
-} // namespace chrome

Powered by Google App Engine
This is Rietveld 408576698