Commit 25abd421 authored by Trent Apted's avatar Trent Apted Committed by Commit Bot

Fix chrome://media-app file handling regression from r720766.

The file handler spec changed in r720766. Update the chrome://media-app
manifest.json to the new spec and add a regression test.

Bug: 1023742
Change-Id: I54cce5105c5193ea4e847e7ebab5a8f590f16201
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1949829
Commit-Queue: Trent Apted <tapted@chromium.org>
Reviewed-by: default avatarJay Harris <harrisjay@chromium.org>
Cr-Commit-Position: refs/heads/master@{#721789}
parent 9e845692
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/path_service.h" #include "base/path_service.h"
#include "base/test/scoped_feature_list.h" #include "base/test/scoped_feature_list.h"
#include "chrome/browser/apps/app_service/app_launch_params.h" #include "chrome/browser/apps/app_service/app_launch_params.h"
#include "chrome/browser/chromeos/file_manager/web_file_tasks.h"
#include "chrome/browser/chromeos/web_applications/system_web_app_integration_test.h" #include "chrome/browser/chromeos/web_applications/system_web_app_integration_test.h"
#include "chrome/browser/web_applications/system_web_app_manager.h" #include "chrome/browser/web_applications/system_web_app_manager.h"
#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_paths.h"
...@@ -13,6 +14,7 @@ ...@@ -13,6 +14,7 @@
#include "chromeos/components/media_app_ui/url_constants.h" #include "chromeos/components/media_app_ui/url_constants.h"
#include "chromeos/constants/chromeos_features.h" #include "chromeos/constants/chromeos_features.h"
#include "content/public/test/test_utils.h" #include "content/public/test/test_utils.h"
#include "extensions/browser/entry_info.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
using web_app::SystemAppType; using web_app::SystemAppType;
...@@ -102,3 +104,29 @@ IN_PROC_BROWSER_TEST_F(MediaAppIntegrationTest, MediaAppLaunchWithFile) { ...@@ -102,3 +104,29 @@ IN_PROC_BROWSER_TEST_F(MediaAppIntegrationTest, MediaAppLaunchWithFile) {
// TODO(crbug/1027030): Add tests for re-launching with new files. // TODO(crbug/1027030): Add tests for re-launching with new files.
} }
// Ensures that chrome://media-app is available as a file task for the ChromeOS
// file manager and eligible for opening appropriate files / mime types.
IN_PROC_BROWSER_TEST_F(MediaAppIntegrationTest, MediaAppElibibleOpenTask) {
constexpr bool kIsDirectory = false;
const extensions::EntryInfo test_entry(TestFile(kFilePng800x600), "image/png",
kIsDirectory);
WaitForTestSystemAppInstall();
std::vector<file_manager::file_tasks::FullTaskDescriptor> result;
file_manager::file_tasks::FindWebTasks(profile(), {test_entry}, &result);
ASSERT_LT(0u, result.size());
EXPECT_EQ(1u, result.size());
const auto& task = result[0];
const auto& descriptor = task.task_descriptor();
EXPECT_EQ("Media App", task.task_title());
EXPECT_EQ(extensions::api::file_manager_private::Verb::VERB_OPEN_WITH,
task.task_verb());
EXPECT_EQ(descriptor.app_id,
*GetManager().GetAppIdForSystemApp(web_app::SystemAppType::MEDIA));
EXPECT_EQ(chromeos::kChromeUIMediaAppURL, descriptor.action_id);
EXPECT_EQ(file_manager::file_tasks::TASK_TYPE_WEB_APP, descriptor.task_type);
}
...@@ -23,13 +23,17 @@ SystemWebAppIntegrationTest::SystemWebAppIntegrationTest() ...@@ -23,13 +23,17 @@ SystemWebAppIntegrationTest::SystemWebAppIntegrationTest()
SystemWebAppIntegrationTest::~SystemWebAppIntegrationTest() = default; SystemWebAppIntegrationTest::~SystemWebAppIntegrationTest() = default;
Profile* SystemWebAppIntegrationTest::profile() {
return browser()->profile();
}
void SystemWebAppIntegrationTest::ExpectSystemWebAppValid( void SystemWebAppIntegrationTest::ExpectSystemWebAppValid(
web_app::SystemAppType app_type, web_app::SystemAppType app_type,
const GURL& url, const GURL& url,
const std::string& title) { const std::string& title) {
Browser* app_browser = WaitForSystemAppInstallAndLaunch(app_type); Browser* app_browser = WaitForSystemAppInstallAndLaunch(app_type);
const extensions::Extension* installed_app = const extensions::Extension* installed_app =
extensions::util::GetInstalledPwaForUrl(browser()->profile(), url); extensions::util::GetInstalledPwaForUrl(profile(), url);
EXPECT_TRUE(GetManager().IsSystemWebApp(installed_app->id())); EXPECT_TRUE(GetManager().IsSystemWebApp(installed_app->id()));
EXPECT_TRUE(installed_app->from_bookmark()); EXPECT_TRUE(installed_app->from_bookmark());
......
...@@ -14,6 +14,8 @@ namespace web_app { ...@@ -14,6 +14,8 @@ namespace web_app {
enum class SystemAppType; enum class SystemAppType;
} }
class Profile;
// Test harness for how ChromeOS System Web Apps integrate with the System Web // Test harness for how ChromeOS System Web Apps integrate with the System Web
// App platform. // App platform.
class SystemWebAppIntegrationTest class SystemWebAppIntegrationTest
...@@ -27,6 +29,9 @@ class SystemWebAppIntegrationTest ...@@ -27,6 +29,9 @@ class SystemWebAppIntegrationTest
void ExpectSystemWebAppValid(web_app::SystemAppType app_type, void ExpectSystemWebAppValid(web_app::SystemAppType app_type,
const GURL& url, const GURL& url,
const std::string& title); const std::string& title);
// Helper to obtain browser()->profile().
Profile* profile();
}; };
#endif // CHROME_BROWSER_CHROMEOS_WEB_APPLICATIONS_SYSTEM_WEB_APP_INTEGRATION_TEST_H_ #endif // CHROME_BROWSER_CHROMEOS_WEB_APPLICATIONS_SYSTEM_WEB_APP_INTEGRATION_TEST_H_
...@@ -12,15 +12,13 @@ ...@@ -12,15 +12,13 @@
"type": "image/png" "type": "image/png"
} }
], ],
"file_handler": { "file_handlers": [
"action": ".", {
"files": [ "action": ".",
{ "name": "Image File",
"name": "Image File", "accept": {
"accept": [ "image/*": [ ]
"image/*"
]
} }
] }
} ]
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment