| 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/extensions/extension.h" | 20 #include "chrome/common/extensions/extension.h" |
| 21 #include "chrome/common/extensions/extension_manifest_constants.h" | 21 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 22 #include "chrome/test/base/testing_profile.h" | 22 #include "chrome/test/base/testing_profile.h" |
| 23 #include "content/public/test/test_browser_thread.h" | 23 #include "content/public/test/test_browser_thread.h" |
| 24 #include "sync/api/string_ordinal.h" |
| 24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 25 | 26 |
| 26 namespace chrome { | 27 namespace chrome { |
| 27 | 28 |
| 28 namespace { | 29 namespace { |
| 29 | 30 |
| 30 class TestMediaGalleriesPreferences : public MediaGalleriesPreferences { | 31 class TestMediaGalleriesPreferences : public MediaGalleriesPreferences { |
| 31 public: | 32 public: |
| 32 static string16 GetDisplayNameForPath(const FilePath& path) { | 33 static string16 GetDisplayNameForPath(const FilePath& path) { |
| 33 return MediaGalleriesPreferences::ComputeDisplayName(path); | 34 return MediaGalleriesPreferences::ComputeDisplayName(path); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 &errors); | 199 &errors); |
| 199 EXPECT_TRUE(extension.get() != NULL) << errors; | 200 EXPECT_TRUE(extension.get() != NULL) << errors; |
| 200 EXPECT_TRUE(extensions::Extension::IdIsValid(extension->id())); | 201 EXPECT_TRUE(extensions::Extension::IdIsValid(extension->id())); |
| 201 if (!extension.get() || | 202 if (!extension.get() || |
| 202 !extensions::Extension::IdIsValid(extension->id())) { | 203 !extensions::Extension::IdIsValid(extension->id())) { |
| 203 return NULL; | 204 return NULL; |
| 204 } | 205 } |
| 205 | 206 |
| 206 extension_service_->extension_prefs()->OnExtensionInstalled( | 207 extension_service_->extension_prefs()->OnExtensionInstalled( |
| 207 extension, extensions::Extension::ENABLED, false, | 208 extension, extensions::Extension::ENABLED, false, |
| 208 StringOrdinal::CreateInitialOrdinal()); | 209 syncer::StringOrdinal::CreateInitialOrdinal()); |
| 209 | 210 |
| 210 return extension; | 211 return extension; |
| 211 } | 212 } |
| 212 | 213 |
| 213 // Needed for extension service & friends to work. | 214 // Needed for extension service & friends to work. |
| 214 MessageLoop loop_; | 215 MessageLoop loop_; |
| 215 content::TestBrowserThread ui_thread_; | 216 content::TestBrowserThread ui_thread_; |
| 216 content::TestBrowserThread file_thread_; | 217 content::TestBrowserThread file_thread_; |
| 217 | 218 |
| 218 scoped_ptr<TestingProfile> profile_; | 219 scoped_ptr<TestingProfile> profile_; |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 // Check that adding one of them again works as expected. | 492 // Check that adding one of them again works as expected. |
| 492 MediaGalleryPrefId id = gallery_prefs()->AddGallery( | 493 MediaGalleryPrefId id = gallery_prefs()->AddGallery( |
| 493 device_id, ASCIIToUTF16("Device2Path2"), path, true /*user*/); | 494 device_id, ASCIIToUTF16("Device2Path2"), path, true /*user*/); |
| 494 EXPECT_EQ(dev2_path2_id, id); | 495 EXPECT_EQ(dev2_path2_id, id); |
| 495 Verify(); | 496 Verify(); |
| 496 } | 497 } |
| 497 | 498 |
| 498 } // namespace | 499 } // namespace |
| 499 | 500 |
| 500 } // namespace chrome | 501 } // namespace chrome |
| OLD | NEW |