Commit c9753d68 authored by Luciano Pacheco's avatar Luciano Pacheco Committed by Commit Bot

Files app: Add test to open image with Backlight

Tests that Files app can open image in Backlight in normal and guest
modes.

Add a new test suite for Files app that installs the SWAs.

Add a new test message to check if a SWA has started.

Bug: 1122379, 1121553
Change-Id: I38313691e71e2d825ae605ecc5b4525e35c499fd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2377765Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Auto-Submit: Luciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#802478}
parent 186593cd
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
#include "chrome/browser/chromeos/file_manager/file_manager_browsertest_base.h" #include "chrome/browser/chromeos/file_manager/file_manager_browsertest_base.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h" #include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/signin/identity_manager_factory.h" #include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/web_applications/system_web_app_manager.h"
#include "chrome/browser/web_applications/web_app_provider.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chromeos/constants/chromeos_switches.h" #include "chromeos/constants/chromeos_switches.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
...@@ -202,6 +204,26 @@ IN_PROC_BROWSER_TEST_P(FilesAppBrowserTest, Test) { ...@@ -202,6 +204,26 @@ IN_PROC_BROWSER_TEST_P(FilesAppBrowserTest, Test) {
StartTest(); StartTest();
} }
// Files app tests that require SWA (System Web Apps).
class SWAsFilesAppBrowserTest : public FilesAppBrowserTest {
public:
SWAsFilesAppBrowserTest() = default;
SWAsFilesAppBrowserTest(const SWAsFilesAppBrowserTest&) = delete;
SWAsFilesAppBrowserTest& operator=(const SWAsFilesAppBrowserTest&) = delete;
void SetUpOnMainThread() override {
web_app::WebAppProvider::Get(profile())
->system_web_app_manager()
.InstallSystemAppsForTesting();
FilesAppBrowserTest::SetUpOnMainThread();
}
};
IN_PROC_BROWSER_TEST_P(SWAsFilesAppBrowserTest, Test) {
StartTest();
}
// A version of the FilesAppBrowserTest that supports spanning browser restart // A version of the FilesAppBrowserTest that supports spanning browser restart
// to allow testing prefs and other things. // to allow testing prefs and other things.
class ExtendedFilesAppBrowserTest : public FilesAppBrowserTest { class ExtendedFilesAppBrowserTest : public FilesAppBrowserTest {
...@@ -299,6 +321,12 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P( ...@@ -299,6 +321,12 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
TestCase("audioNoRepeatModeMultipleFileDrive"), TestCase("audioNoRepeatModeMultipleFileDrive"),
TestCase("audioRepeatOneModeMultipleFileDrive"))); TestCase("audioRepeatOneModeMultipleFileDrive")));
WRAPPED_INSTANTIATE_TEST_SUITE_P(
OpenImageBacklight, /* open_image_backlight.js */
SWAsFilesAppBrowserTest,
::testing::Values(TestCase("imageOpenBacklight").InGuestMode(),
TestCase("imageOpenBacklight")));
WRAPPED_INSTANTIATE_TEST_SUITE_P( WRAPPED_INSTANTIATE_TEST_SUITE_P(
OpenImageFiles, /* open_image_files.js */ OpenImageFiles, /* open_image_files.js */
FilesAppBrowserTest, FilesAppBrowserTest,
......
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
#include "base/test/bind_test_util.h" #include "base/test/bind_test_util.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h"
#include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.h" #include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.h"
#include "chrome/browser/chromeos/arc/fileapi/arc_media_view_util.h" #include "chrome/browser/chromeos/arc/fileapi/arc_media_view_util.h"
...@@ -2306,6 +2308,24 @@ void FileManagerBrowserTestBase::OnCommand(const std::string& name, ...@@ -2306,6 +2308,24 @@ void FileManagerBrowserTestBase::OnCommand(const std::string& name,
return; return;
} }
if (name == "hasSwaStarted") {
std::string swa_app_id;
ASSERT_TRUE(value.GetString("swaAppId", &swa_app_id));
*output = "false";
auto* proxy = apps::AppServiceProxyFactory::GetForProfile(profile());
proxy->InstanceRegistry().ForEachInstance(
[&swa_app_id, &output](const apps::InstanceUpdate& update) {
if (update.AppId() == swa_app_id &&
update.State() & apps::InstanceState::kStarted) {
*output = "true";
}
});
return;
}
if (name == "countAppWindows") { if (name == "countAppWindows") {
std::string app_id; std::string app_id;
ASSERT_TRUE(value.GetString("appId", &app_id)); ASSERT_TRUE(value.GetString("appId", &app_id));
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
'use strict';
(() => {
const BACKLIGHT_APP_ID = 'jhdjimmaggjajfjphpljagpgkidjilnj';
/** Tests opening an image opens Backlight. */
testcase.imageOpenBacklight = async () => {
await sendTestMessage({
name: 'expectFileTask',
fileNames: [ENTRIES.image3.targetPath],
openType: 'launch'
});
// Open Files.App on Downloads, add image3 to Downloads.
const filesAppId =
await setupAndWaitUntilReady(RootPath.DOWNLOADS, [ENTRIES.image3], []);
// Open the image file in Files app.
chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
'openFile', filesAppId, [ENTRIES.image3.targetPath]));
// Wait for Backlight to open.
const caller = getCaller();
await repeatUntil(async () => {
const result = await sendTestMessage({
name: 'hasSwaStarted',
swaAppId: BACKLIGHT_APP_ID,
});
if (result !== 'true') {
return pending(caller, 'Waiting for Backlight to open');
}
});
};
})();
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
"file_manager/metrics.js", "file_manager/metrics.js",
"file_manager/my_files.js", "file_manager/my_files.js",
"file_manager/open_audio_files.js", "file_manager/open_audio_files.js",
"file_manager/open_image_backlight.js",
"file_manager/open_image_files.js", "file_manager/open_image_files.js",
"file_manager/open_sniffed_files.js", "file_manager/open_sniffed_files.js",
"file_manager/open_video_files.js", "file_manager/open_video_files.js",
......
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