Commit f2d4c81b authored by Anand K. Mistry's avatar Anand K. Mistry Committed by Commit Bot

Preload zip archiver NaCl module for zip browser tests.

In DEBUG builds, the PNaCl translation takes a significant amount of
time, causing zip browser test TIMEOUT flakes on the bots.

Recover the FilesApp browser test feature used to declare ZipTests and
for the zip browser tests, tell the zip-archiver extension to preload
the NaCl module before it's needed, so its translation starts as early
as possible during zip browser tests.

BUG=889703

Change-Id: Ic16a4b4e53a4be88bae8ee5d2c2caa8baaa1487b
Reviewed-on: https://chromium-review.googlesource.com/c/1257464Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Commit-Queue: Anand Mistry <amistry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596470}
parent 87bb2f9b
...@@ -86,6 +86,7 @@ struct TestCase { ...@@ -86,6 +86,7 @@ struct TestCase {
bool tablet_mode = false; bool tablet_mode = false;
bool enable_drivefs = false; bool enable_drivefs = false;
bool with_browser = false; bool with_browser = false;
bool needs_zip = false;
bool offline = false; bool offline = false;
}; };
...@@ -96,6 +97,11 @@ struct EventCase : public TestCase { ...@@ -96,6 +97,11 @@ struct EventCase : public TestCase {
} }
}; };
// ZipCase: FilesAppBrowserTest with zip/unzip support.
struct ZipCase : public TestCase {
explicit ZipCase(const char* name) : TestCase(name) { needs_zip = true; }
};
// FilesApp browser test. // FilesApp browser test.
class FilesAppBrowserTest : public FileManagerBrowserTestBase, class FilesAppBrowserTest : public FileManagerBrowserTestBase,
public ::testing::WithParamInterface<TestCase> { public ::testing::WithParamInterface<TestCase> {
...@@ -147,6 +153,8 @@ class FilesAppBrowserTest : public FileManagerBrowserTestBase, ...@@ -147,6 +153,8 @@ class FilesAppBrowserTest : public FileManagerBrowserTestBase,
return GetParam().with_browser; return GetParam().with_browser;
} }
bool GetNeedsZipSupport() const override { return GetParam().needs_zip; }
bool GetIsOffline() const override { return GetParam().offline; } bool GetIsOffline() const override { return GetParam().offline; }
private: private:
...@@ -237,16 +245,16 @@ WRAPPED_INSTANTIATE_TEST_CASE_P( ...@@ -237,16 +245,16 @@ WRAPPED_INSTANTIATE_TEST_CASE_P(
WRAPPED_INSTANTIATE_TEST_CASE_P( WRAPPED_INSTANTIATE_TEST_CASE_P(
MAYBE_ZipFiles, /* zip_files.js */ MAYBE_ZipFiles, /* zip_files.js */
FilesAppBrowserTest, FilesAppBrowserTest,
::testing::Values(TestCase("zipFileOpenDownloads").InGuestMode(), ::testing::Values(ZipCase("zipFileOpenDownloads").InGuestMode(),
TestCase("zipFileOpenDownloads"), ZipCase("zipFileOpenDownloads"),
TestCase("zipFileOpenDrive").EnableDriveFs(), ZipCase("zipFileOpenDrive").EnableDriveFs(),
TestCase("zipFileOpenDrive"), ZipCase("zipFileOpenDrive"),
TestCase("zipFileOpenUsb"), ZipCase("zipFileOpenUsb"),
TestCase("zipCreateFileDownloads").InGuestMode(), ZipCase("zipCreateFileDownloads").InGuestMode(),
TestCase("zipCreateFileDownloads"), ZipCase("zipCreateFileDownloads"),
TestCase("zipCreateFileDrive").EnableDriveFs(), ZipCase("zipCreateFileDrive").EnableDriveFs(),
TestCase("zipCreateFileDrive"), ZipCase("zipCreateFileDrive"),
TestCase("zipCreateFileUsb"))); ZipCase("zipCreateFileUsb")));
WRAPPED_INSTANTIATE_TEST_CASE_P( WRAPPED_INSTANTIATE_TEST_CASE_P(
CreateNewFolder, /* create_new_folder.js */ CreateNewFolder, /* create_new_folder.js */
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "chrome/browser/chromeos/crostini/crostini_pref_names.h" #include "chrome/browser/chromeos/crostini/crostini_pref_names.h"
#include "chrome/browser/chromeos/crostini/crostini_util.h" #include "chrome/browser/chromeos/crostini/crostini_util.h"
#include "chrome/browser/chromeos/drive/file_system_util.h" #include "chrome/browser/chromeos/drive/file_system_util.h"
#include "chrome/browser/chromeos/file_manager/app_id.h"
#include "chrome/browser/chromeos/file_manager/file_manager_test_util.h" #include "chrome/browser/chromeos/file_manager/file_manager_test_util.h"
#include "chrome/browser/chromeos/file_manager/mount_test_util.h" #include "chrome/browser/chromeos/file_manager/mount_test_util.h"
#include "chrome/browser/chromeos/file_manager/path_util.h" #include "chrome/browser/chromeos/file_manager/path_util.h"
...@@ -55,8 +56,10 @@ ...@@ -55,8 +56,10 @@
#include "content/public/common/service_manager_connection.h" #include "content/public/common/service_manager_connection.h"
#include "content/public/test/test_utils.h" #include "content/public/test/test_utils.h"
#include "extensions/browser/api/test/test_api.h" #include "extensions/browser/api/test/test_api.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_function_registry.h" #include "extensions/browser/extension_function_registry.h"
#include "extensions/browser/notification_types.h" #include "extensions/browser/notification_types.h"
#include "extensions/common/api/test.h"
#include "google_apis/drive/drive_api_parser.h" #include "google_apis/drive/drive_api_parser.h"
#include "google_apis/drive/test_util.h" #include "google_apis/drive/test_util.h"
#include "media/base/media_switches.h" #include "media/base/media_switches.h"
...@@ -1159,6 +1162,10 @@ bool FileManagerBrowserTestBase::GetRequiresStartupBrowser() const { ...@@ -1159,6 +1162,10 @@ bool FileManagerBrowserTestBase::GetRequiresStartupBrowser() const {
return false; return false;
} }
bool FileManagerBrowserTestBase::GetNeedsZipSupport() const {
return false;
}
bool FileManagerBrowserTestBase::GetIsOffline() const { bool FileManagerBrowserTestBase::GetIsOffline() const {
return false; return false;
} }
...@@ -1243,6 +1250,21 @@ void FileManagerBrowserTestBase::OnCommand(const std::string& name, ...@@ -1243,6 +1250,21 @@ void FileManagerBrowserTestBase::OnCommand(const std::string& name,
return; return;
} }
if (name == "zipArchiverLoaded") {
if (IsZipTest()) {
LOG(INFO) << "Preloading zip archiver NaCl module";
auto event = std::make_unique<extensions::Event>(
extensions::events::FOR_TEST,
extensions::api::test::OnMessage::kEventName,
base::ListValue::From(base::JSONReader::Read(
R"([{"data": "preloadZip", "lastMessage": false}])")),
profile());
extensions::EventRouter::Get(profile())->DispatchEventToExtension(
kZipArchiverId, std::move(event));
}
return;
}
if (name == "getRootPaths") { if (name == "getRootPaths") {
// Obtain the root paths. // Obtain the root paths.
const auto downloads_root = util::GetDownloadsMountPointName(profile()); const auto downloads_root = util::GetDownloadsMountPointName(profile());
......
...@@ -50,6 +50,7 @@ class FileManagerBrowserTestBase : public extensions::ExtensionApiTest { ...@@ -50,6 +50,7 @@ class FileManagerBrowserTestBase : public extensions::ExtensionApiTest {
virtual bool GetTabletMode() const; virtual bool GetTabletMode() const;
virtual bool GetEnableDriveFs() const; virtual bool GetEnableDriveFs() const;
virtual bool GetRequiresStartupBrowser() const; virtual bool GetRequiresStartupBrowser() const;
virtual bool GetNeedsZipSupport() const;
virtual bool GetIsOffline() const; virtual bool GetIsOffline() const;
// Launches the test extension from GetTestExtensionManifestName() and uses // Launches the test extension from GetTestExtensionManifestName() and uses
...@@ -70,6 +71,9 @@ class FileManagerBrowserTestBase : public extensions::ExtensionApiTest { ...@@ -70,6 +71,9 @@ class FileManagerBrowserTestBase : public extensions::ExtensionApiTest {
// Returns true if the test requires DriveFS. // Returns true if the test requires DriveFS.
bool IsDriveFsTest() const { return GetEnableDriveFs(); } bool IsDriveFsTest() const { return GetEnableDriveFs(); }
// Returns true if the test requires zip/unzip support.
bool IsZipTest() const { return GetNeedsZipSupport(); }
// Returns true if Drive should act as if offline. // Returns true if Drive should act as if offline.
bool IsOfflineTest() const { return GetIsOffline(); } bool IsOfflineTest() const { return GetIsOffline(); }
......
...@@ -4,6 +4,18 @@ ...@@ -4,6 +4,18 @@
'use strict'; 'use strict';
if (chrome.test) {
chrome.test.onMessage.addListener((msg) => {
if (msg.data != 'preloadZip')
return;
console.info('Preloading NaCl module');
unpacker.app.loadNaclModule(
unpacker.app.DEFAULT_MODULE_NMF, unpacker.app.DEFAULT_MODULE_TYPE);
});
chrome.test.sendMessage(JSON.stringify({name: 'zipArchiverLoaded'}));
}
function setupZipArchiver() { function setupZipArchiver() {
chrome.fileSystemProvider.onUnmountRequested.addListener( chrome.fileSystemProvider.onUnmountRequested.addListener(
unpacker.app.onUnmountRequested); unpacker.app.onUnmountRequested);
......
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