Commit a1b6965a authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

[filesapp] Add a files app SWA load test

Add a files app SWA integration test: test that files app SWA loads in
the files app browser test harness.

Remember the SWA web_contents so we can shut it down at the end of the
test. Supports only one running files app SWA instance for now.

Test: browser_tests --gtest_filter="*launchFilesAppSwa*"
Bug: 1113981
Change-Id: I78b4fafab57622fecc134b009858554bdcb05126
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2507316
Commit-Queue: Noel Gordon <noel@chromium.org>
Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Reviewed-by: default avatarAlex Danilo <adanilo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822544}
parent f440f42d
......@@ -991,6 +991,12 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
FilesAppBrowserTest,
::testing::Values(TestCase("installLinuxPackageDialog")));
WRAPPED_INSTANTIATE_TEST_SUITE_P(
LaunchFilesAppSwa, /* launch_files_app_swa.js */
FilesAppBrowserTest,
::testing::Values(TestCase("launchFilesAppSwa").FilesSwa(),
TestCase("launchFilesAppSwa").FilesSwa().InGuestMode()));
WRAPPED_INSTANTIATE_TEST_SUITE_P(
LauncherSearch, /* launcher_search.js */
FilesAppBrowserTest,
......
......@@ -28,8 +28,10 @@
#include "base/test/bind_test_util.h"
#include "base/threading/thread_restrictions.h"
#include "base/time/time.h"
#include "chrome/browser/apps/app_service/app_launch_params.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/apps/app_service/browser_app_launcher.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_media_view_util.h"
......@@ -1882,6 +1884,10 @@ void FileManagerBrowserTestBase::SetUpOnMainThread() {
}
void FileManagerBrowserTestBase::TearDownOnMainThread() {
if (files_app_web_contents_) {
files_app_web_contents_->Close();
}
file_tasks_observer_.reset();
select_factory_ = nullptr;
ui::SelectFileDialog::SetFactory(nullptr);
......@@ -2010,6 +2016,26 @@ void FileManagerBrowserTestBase::OnCommand(const std::string& name,
return;
}
if (name == "launchFileManagerSwa") {
apps::AppLaunchParams params(
files_app_swa_id_, apps::mojom::LaunchContainer::kLaunchContainerWindow,
WindowOpenDisposition::NEW_FOREGROUND_TAB,
apps::mojom::AppLaunchSource::kSourceTest);
content::WebContents* web_contents =
apps::AppServiceProxyFactory::GetForProfile(profile())
->BrowserAppLauncher()
->LaunchAppWithParams(std::move(params));
CHECK(web_contents);
content::WaitForLoadStop(web_contents);
LOG(INFO) << name << " url " << web_contents->GetLastCommittedURL();
files_app_web_contents_ = web_contents;
*output = files_app_swa_id_;
return;
}
if (name == "launchAppOnDrive") {
auto* integration_service =
drive::DriveIntegrationServiceFactory::FindForProfile(profile());
......
......@@ -28,6 +28,10 @@ namespace arc {
class FakeFileSystemInstance;
} // namespace arc
namespace content {
class WebContents;
} // namespace content
namespace file_manager {
enum GuestMode { NOT_IN_GUEST_MODE, IN_GUEST_MODE, IN_INCOGNITO };
......@@ -179,6 +183,7 @@ class FileManagerBrowserTestBase : public content::DevToolsAgentHostObserver,
bool IsSmbEnabled() const;
web_app::AppId files_app_swa_id_;
content::WebContents* files_app_web_contents_ = nullptr;
std::unique_ptr<base::test::ScopedFeatureList> feature_list_;
crostini::FakeCrostiniFeatures crostini_features_;
......
// 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';
(() => {
/**
* Tests that files app SWA launches.
*/
testcase.launchFilesAppSwa = async () => {
const caller = getCaller();
const swaAppId = await sendTestMessage({
name: 'launchFileManagerSwa',
});
console.log('file_manager_swa_id: ' + swaAppId);
await repeatUntil(async () => {
const launched = await sendTestMessage({
name: 'hasSwaStarted',
swaAppId: swaAppId,
});
if (launched !== 'true') {
return pending(caller, 'Waiting for files app SWA launch');
}
});
return IGNORE_APP_ERRORS;
};
})();
......@@ -31,6 +31,7 @@
"file_manager/grid_view.js",
"file_manager/install_linux_package_dialog.js",
"file_manager/keyboard_operations.js",
"file_manager/launch_files_app_swa.js",
"file_manager/launcher_search.js",
"file_manager/metadata.js",
"file_manager/metrics.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