| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/extensions/extension_apitest.h" | 11 #include "chrome/browser/extensions/extension_apitest.h" |
| 12 #include "chrome/browser/extensions/extension_process_manager.h" | 12 #include "chrome/browser/extensions/extension_process_manager.h" |
| 13 #include "chrome/browser/extensions/extension_system.h" |
| 13 #include "chrome/browser/extensions/platform_app_browsertest_util.h" | 14 #include "chrome/browser/extensions/platform_app_browsertest_util.h" |
| 14 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/common/chrome_paths.h" | 16 #include "chrome/common/chrome_paths.h" |
| 16 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
| 17 #include "content/public/browser/render_view_host.h" | 18 #include "content/public/browser/render_view_host.h" |
| 18 | 19 |
| 19 #if defined(OS_LINUX) | 20 #if defined(OS_LINUX) |
| 20 #include "base/environment.h" | 21 #include "base/environment.h" |
| 21 #include "base/scoped_temp_dir.h" | 22 #include "base/scoped_temp_dir.h" |
| 22 #endif | 23 #endif |
| (...skipping 10 matching lines...) Expand all Loading... |
| 33 } | 34 } |
| 34 }; | 35 }; |
| 35 | 36 |
| 36 class PlatformAppMediaGalleriesBrowserTest : public PlatformAppBrowserTest { | 37 class PlatformAppMediaGalleriesBrowserTest : public PlatformAppBrowserTest { |
| 37 protected: | 38 protected: |
| 38 // Since ExtensionTestMessageListener does not work with RunPlatformAppTest(), | 39 // Since ExtensionTestMessageListener does not work with RunPlatformAppTest(), |
| 39 // This helper method can be used to run additional media gallery tests. | 40 // This helper method can be used to run additional media gallery tests. |
| 40 void RunSecondTestPhase(int expected_galleries) { | 41 void RunSecondTestPhase(int expected_galleries) { |
| 41 const extensions::Extension* extension = GetSingleLoadedExtension(); | 42 const extensions::Extension* extension = GetSingleLoadedExtension(); |
| 42 extensions::ExtensionHost* host = | 43 extensions::ExtensionHost* host = |
| 43 browser()->profile()->GetExtensionProcessManager()-> | 44 extensions::ExtensionSystem::Get(browser()->profile())-> |
| 44 GetBackgroundHostForExtension(extension->id()); | 45 process_manager()->GetBackgroundHostForExtension(extension->id()); |
| 45 ASSERT_TRUE(host); | 46 ASSERT_TRUE(host); |
| 46 | 47 |
| 47 static const char kTestGalleries[] = "testGalleries(%d)"; | 48 static const char kTestGalleries[] = "testGalleries(%d)"; |
| 48 ResultCatcher catcher; | 49 ResultCatcher catcher; |
| 49 host->render_view_host()->ExecuteJavascriptInWebFrame( | 50 host->render_view_host()->ExecuteJavascriptInWebFrame( |
| 50 string16(), | 51 string16(), |
| 51 ASCIIToUTF16(base::StringPrintf(kTestGalleries, expected_galleries))); | 52 ASCIIToUTF16(base::StringPrintf(kTestGalleries, expected_galleries))); |
| 52 EXPECT_TRUE(catcher.GetNextResult()) << message_; | 53 EXPECT_TRUE(catcher.GetNextResult()) << message_; |
| 53 } | 54 } |
| 54 }; | 55 }; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 EnsureMediaDirectoriesExists media_directories; | 142 EnsureMediaDirectoriesExists media_directories; |
| 142 ASSERT_TRUE(RunPlatformAppTest("api_test/media_galleries/no_access")) | 143 ASSERT_TRUE(RunPlatformAppTest("api_test/media_galleries/no_access")) |
| 143 << message_; | 144 << message_; |
| 144 RunSecondTestPhase(media_directories.num_galleries()); | 145 RunSecondTestPhase(media_directories.num_galleries()); |
| 145 } | 146 } |
| 146 | 147 |
| 147 IN_PROC_BROWSER_TEST_F(ExperimentalMediaGalleriesApiTest, | 148 IN_PROC_BROWSER_TEST_F(ExperimentalMediaGalleriesApiTest, |
| 148 ExperimentalMediaGalleries) { | 149 ExperimentalMediaGalleries) { |
| 149 ASSERT_TRUE(RunExtensionTest("media_galleries/experimental")) << message_; | 150 ASSERT_TRUE(RunExtensionTest("media_galleries/experimental")) << message_; |
| 150 } | 151 } |
| OLD | NEW |