| 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 // MediaGalleriesPrivate gallery watch API browser tests. | 5 // MediaGalleriesPrivate gallery watch API browser tests. |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/files/file_path_watcher.h" | 8 #include "base/files/file_path_watcher.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/extensions/extension_apitest.h" | 15 #include "chrome/browser/extensions/extension_apitest.h" |
| 16 #include "chrome/browser/extensions/extension_service.h" | |
| 17 #include "chrome/browser/media_galleries/media_file_system_registry.h" | 16 #include "chrome/browser/media_galleries/media_file_system_registry.h" |
| 18 #include "chrome/browser/media_galleries/media_galleries_preferences.h" | 17 #include "chrome/browser/media_galleries/media_galleries_preferences.h" |
| 19 #include "chrome/browser/media_galleries/media_galleries_test_util.h" | 18 #include "chrome/browser/media_galleries/media_galleries_test_util.h" |
| 20 #include "chrome/common/chrome_paths.h" | 19 #include "chrome/common/chrome_paths.h" |
| 21 #include "content/public/browser/render_frame_host.h" | 20 #include "content/public/browser/render_frame_host.h" |
| 22 #include "content/public/browser/render_view_host.h" | 21 #include "content/public/browser/render_view_host.h" |
| 23 #include "extensions/browser/extension_system.h" | 22 #include "extensions/browser/process_manager.h" |
| 24 #include "extensions/common/extension.h" | 23 #include "extensions/common/extension.h" |
| 25 #include "extensions/common/switches.h" | 24 #include "extensions/common/switches.h" |
| 26 #include "extensions/test/extension_test_message_listener.h" | 25 #include "extensions/test/extension_test_message_listener.h" |
| 27 | 26 |
| 28 namespace { | 27 namespace { |
| 29 | 28 |
| 30 // Id of test extension from | 29 // Id of test extension from |
| 31 // chrome/test/data/extensions/api_test/|kTestExtensionPath| | 30 // chrome/test/data/extensions/api_test/|kTestExtensionPath| |
| 32 const char kTestExtensionId[] = "gceegfkgibmgpfopknlcgleimclbknie"; | 31 const char kTestExtensionId[] = "gceegfkgibmgpfopknlcgleimclbknie"; |
| 33 const char kTestExtensionPath[] = "media_galleries_private/gallerywatch"; | 32 const char kTestExtensionPath[] = "media_galleries_private/gallerywatch"; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 126 |
| 128 ExtensionTestMessageListener add_gallery_watch_finished( | 127 ExtensionTestMessageListener add_gallery_watch_finished( |
| 129 expected_result, false /* no reply */); | 128 expected_result, false /* no reply */); |
| 130 ExecuteCmdAndCheckReply(kSetupWatchOnValidGalleriesCmd, kAddGalleryWatchOK); | 129 ExecuteCmdAndCheckReply(kSetupWatchOnValidGalleriesCmd, kAddGalleryWatchOK); |
| 131 EXPECT_TRUE(add_gallery_watch_finished.WaitUntilSatisfied()); | 130 EXPECT_TRUE(add_gallery_watch_finished.WaitUntilSatisfied()); |
| 132 } | 131 } |
| 133 | 132 |
| 134 private: | 133 private: |
| 135 void GetBackgroundHostForTestExtension() { | 134 void GetBackgroundHostForTestExtension() { |
| 136 ASSERT_TRUE(extension_); | 135 ASSERT_TRUE(extension_); |
| 137 extensions::ExtensionSystem* extension_system = | 136 background_host_ = extensions::ProcessManager::Get(browser()->profile()) |
| 138 extensions::ExtensionSystem::Get(browser()->profile()); | 137 ->GetBackgroundHostForExtension(extension_->id()) |
| 139 background_host_ = | 138 ->render_view_host(); |
| 140 extension_system->process_manager()->GetBackgroundHostForExtension( | |
| 141 extension_->id())->render_view_host(); | |
| 142 ASSERT_TRUE(background_host_); | 139 ASSERT_TRUE(background_host_); |
| 143 } | 140 } |
| 144 | 141 |
| 145 void CreateTestGallery() { | 142 void CreateTestGallery() { |
| 146 MediaGalleriesPreferences* preferences = | 143 MediaGalleriesPreferences* preferences = |
| 147 g_browser_process->media_file_system_registry()->GetPreferences( | 144 g_browser_process->media_file_system_registry()->GetPreferences( |
| 148 browser()->profile()); | 145 browser()->profile()); |
| 149 base::RunLoop runloop; | 146 base::RunLoop runloop; |
| 150 preferences->EnsureInitialized(runloop.QuitClosure()); | 147 preferences->EnsureInitialized(runloop.QuitClosure()); |
| 151 runloop.Run(); | 148 runloop.Run(); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 // Remove all gallery watchers. | 334 // Remove all gallery watchers. |
| 338 ExecuteCmdAndCheckReply(kRemoveAllGalleryWatchCmd, kRemoveAllGalleryWatchOK); | 335 ExecuteCmdAndCheckReply(kRemoveAllGalleryWatchCmd, kRemoveAllGalleryWatchOK); |
| 339 | 336 |
| 340 // Gallery watchers removed. chrome.mediaGalleriesPrivate.getAllGalleryWatch | 337 // Gallery watchers removed. chrome.mediaGalleriesPrivate.getAllGalleryWatch |
| 341 // should return an empty list. | 338 // should return an empty list. |
| 342 ExtensionTestMessageListener final_get_all_check_finished( | 339 ExtensionTestMessageListener final_get_all_check_finished( |
| 343 kNoGalleryWatchesInstalled, false /* no reply */); | 340 kNoGalleryWatchesInstalled, false /* no reply */); |
| 344 ExecuteCmdAndCheckReply(kGetAllWatchedGalleryIdsCmd, kGetAllGalleryWatchOK); | 341 ExecuteCmdAndCheckReply(kGetAllWatchedGalleryIdsCmd, kGetAllGalleryWatchOK); |
| 345 EXPECT_TRUE(final_get_all_check_finished.WaitUntilSatisfied()); | 342 EXPECT_TRUE(final_get_all_check_finished.WaitUntilSatisfied()); |
| 346 } | 343 } |
| OLD | NEW |