| 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 // MediaGalleriesPreferences unit tests. | 5 // MediaGalleriesPreferences unit tests. |
| 6 | 6 |
| 7 #include "chrome/browser/media_gallery/media_galleries_preferences.h" | 7 #include "chrome/browser/media_gallery/media_galleries_preferences.h" |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
| 17 #include "chrome/browser/extensions/extension_system.h" | 17 #include "chrome/browser/extensions/extension_system.h" |
| 18 #include "chrome/browser/extensions/test_extension_system.h" | 18 #include "chrome/browser/extensions/test_extension_system.h" |
| 19 #include "chrome/browser/media_gallery/media_file_system_registry.h" | 19 #include "chrome/browser/media_gallery/media_file_system_registry.h" |
| 20 #include "chrome/common/chrome_switches.h" | |
| 21 #include "chrome/common/extensions/extension.h" | 20 #include "chrome/common/extensions/extension.h" |
| 22 #include "chrome/common/extensions/extension_manifest_constants.h" | 21 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 23 #include "chrome/test/base/testing_profile.h" | 22 #include "chrome/test/base/testing_profile.h" |
| 24 #include "content/public/test/test_browser_thread.h" | 23 #include "content/public/test/test_browser_thread.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 26 | 25 |
| 27 namespace chrome { | 26 namespace chrome { |
| 28 | 27 |
| 29 namespace { | 28 namespace { |
| 30 | 29 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 49 } | 48 } |
| 50 | 49 |
| 51 virtual ~MediaGalleriesPreferencesTest() { | 50 virtual ~MediaGalleriesPreferencesTest() { |
| 52 // TestExtensionSystem uses DeleteSoon, so we need to delete the profile | 51 // TestExtensionSystem uses DeleteSoon, so we need to delete the profile |
| 53 // and then run the message queue to clean up. | 52 // and then run the message queue to clean up. |
| 54 profile_.reset(); | 53 profile_.reset(); |
| 55 MessageLoop::current()->RunAllPending(); | 54 MessageLoop::current()->RunAllPending(); |
| 56 } | 55 } |
| 57 | 56 |
| 58 virtual void SetUp() OVERRIDE { | 57 virtual void SetUp() OVERRIDE { |
| 59 CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 60 switches::kEnableMediaGalleryUI); | |
| 61 extensions_dir_ = profile_->GetPath().AppendASCII("Extensions"); | 58 extensions_dir_ = profile_->GetPath().AppendASCII("Extensions"); |
| 62 ASSERT_TRUE(file_util::CreateDirectory(extensions_dir_)); | 59 ASSERT_TRUE(file_util::CreateDirectory(extensions_dir_)); |
| 63 | 60 |
| 64 extensions::TestExtensionSystem* extension_system( | 61 extensions::TestExtensionSystem* extension_system( |
| 65 static_cast<extensions::TestExtensionSystem*>( | 62 static_cast<extensions::TestExtensionSystem*>( |
| 66 extensions::ExtensionSystem::Get(profile_.get()))); | 63 extensions::ExtensionSystem::Get(profile_.get()))); |
| 67 extension_service_ = extension_system->CreateExtensionService( | 64 extension_service_ = extension_system->CreateExtensionService( |
| 68 CommandLine::ForCurrentProcess(), extensions_dir_, false); | 65 CommandLine::ForCurrentProcess(), extensions_dir_, false); |
| 69 | 66 |
| 70 MediaGalleriesPreferences::RegisterUserPrefs(profile_->GetPrefs()); | |
| 71 gallery_prefs_.reset(new MediaGalleriesPreferences(profile_.get())); | 67 gallery_prefs_.reset(new MediaGalleriesPreferences(profile_.get())); |
| 72 | 68 |
| 73 // Load the default galleries into the expectations. | 69 // Load the default galleries into the expectations. |
| 74 if (gallery_prefs_->known_galleries().size()) { | 70 if (gallery_prefs_->known_galleries().size()) { |
| 75 const MediaGalleriesPrefInfoMap& known_galleries = | 71 const MediaGalleriesPrefInfoMap& known_galleries = |
| 76 gallery_prefs_->known_galleries(); | 72 gallery_prefs_->known_galleries(); |
| 77 ASSERT_EQ(1U, known_galleries.size()); | 73 ASSERT_EQ(1U, known_galleries.size()); |
| 78 default_galleries_count_ = 1; | 74 default_galleries_count_ = 1; |
| 79 MediaGalleriesPrefInfoMap::const_iterator it = known_galleries.begin(); | 75 MediaGalleriesPrefInfoMap::const_iterator it = known_galleries.begin(); |
| 80 expected_galleries_[it->first] = it->second; | 76 expected_galleries_[it->first] = it->second; |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 // Check that adding one of them again works as expected. | 491 // Check that adding one of them again works as expected. |
| 496 MediaGalleryPrefId id = gallery_prefs()->AddGallery( | 492 MediaGalleryPrefId id = gallery_prefs()->AddGallery( |
| 497 device_id, ASCIIToUTF16("Device2Path2"), path, true /*user*/); | 493 device_id, ASCIIToUTF16("Device2Path2"), path, true /*user*/); |
| 498 EXPECT_EQ(dev2_path2_id, id); | 494 EXPECT_EQ(dev2_path2_id, id); |
| 499 Verify(); | 495 Verify(); |
| 500 } | 496 } |
| 501 | 497 |
| 502 } // namespace | 498 } // namespace |
| 503 | 499 |
| 504 } // namespace chrome | 500 } // namespace chrome |
| OLD | NEW |