Commit 9a5d26bf authored by mtomasz's avatar mtomasz Committed by Commit bot

Add a test for requesting mount via a context menu in Files app.

TEST=browser_tests: *Providers/FileSystemBrowserTest*
BUG=486864

Review URL: https://codereview.chromium.org/1145893002

Cr-Commit-Position: refs/heads/master@{#330715}
parent a0933169
......@@ -546,6 +546,9 @@ class FileManagerBrowserTestBase : public ExtensionApiTest {
// Adds an incognito and guest-mode flags for tests in the guest mode.
void SetUpCommandLine(base::CommandLine* command_line) override;
// Installs an extension at the specified |path| using the |manifest_name|
// manifest.
void InstallExtension(const base::FilePath& path, const char* manifest_name);
// Loads our testing extension and sends it a string identifying the current
// test.
virtual void StartTest();
......@@ -621,17 +624,22 @@ void FileManagerBrowserTestBase::SetUpCommandLine(
ExtensionApiTest::SetUpCommandLine(command_line);
}
void FileManagerBrowserTestBase::StartTest() {
void FileManagerBrowserTestBase::InstallExtension(const base::FilePath& path,
const char* manifest_name) {
base::FilePath root_path;
ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &root_path));
// Launch the extension.
const base::FilePath path =
root_path.Append(FILE_PATH_LITERAL("ui/file_manager/integration_tests"));
const base::FilePath absolute_path = root_path.Append(path);
const extensions::Extension* const extension =
LoadExtensionAsComponentWithManifest(path, GetTestManifestName());
LoadExtensionAsComponentWithManifest(absolute_path, manifest_name);
ASSERT_TRUE(extension);
}
void FileManagerBrowserTestBase::StartTest() {
InstallExtension(
base::FilePath(FILE_PATH_LITERAL("ui/file_manager/integration_tests")),
GetTestManifestName());
RunTestMessageLoop();
}
......@@ -785,6 +793,13 @@ void FileManagerBrowserTestBase::OnMessage(const std::string& name,
return;
}
if (name == "installProviderExtension") {
InstallExtension(base::FilePath(FILE_PATH_LITERAL(
"ui/file_manager/integration_tests/testing_provider")),
"manifest.json");
return;
}
FAIL() << "Unknown test message: " << name;
}
......@@ -1209,6 +1224,11 @@ WRAPPED_INSTANTIATE_TEST_CASE_P(
TestParameter(IN_GUEST_MODE, "showGridViewDownloads"),
TestParameter(NOT_IN_GUEST_MODE, "showGridViewDrive")));
WRAPPED_INSTANTIATE_TEST_CASE_P(
Providers,
FileManagerBrowserTest,
::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "requestMount")));
// Structure to describe an account info.
struct TestAccountInfo {
const char* const gaia_id;
......
// Copyright 2015 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';
(function() {
/**
* Tests if mounting a provided file system via the "Add new services" button
* works correctly.
*/
function requestMount() {
var appId;
StepsRunner.run([
function() {
chrome.test.sendMessage(
JSON.stringify({name: 'installProviderExtension'}));
setupAndWaitUntilReady(null, RootPath.DOWNLOADS, this.next);
},
function(inAppId) {
appId = inAppId;
remoteCall.callRemoteTestUtil(
'fakeMouseClick',
appId,
['div[menu=\'#add-new-services-menu\']'],
this.next);
},
function(result) {
chrome.test.assertTrue(result);
remoteCall.waitForElement(
appId,
'#add-new-services-menu:not([hidden]) cr-menu-item:first-child span')
.then(this.next);
},
function(result) {
chrome.test.assertEq('Testing Provider', result.text);
remoteCall.callRemoteTestUtil(
'fakeMouseClick',
appId,
['#add-new-services-menu cr-menu-item:first-child span'],
this.next);
},
function(result) {
remoteCall.waitForElement(
appId,
'.tree-row[selected] .icon[volume-type-icon="provided"]')
.then(this.next);
},
function(result) {
remoteCall.callRemoteTestUtil(
'fakeMouseClick',
appId,
['div[menu=\'#add-new-services-menu\']'],
this.next);
},
function(result) {
chrome.test.assertTrue(result);
// Confirm that the first element of the menu is now the separator, as
// the extension once mounted should be gone from the menu, as it doesn't
// support multiple mounts.
remoteCall.waitForElement(
appId,
'#add-new-services-menu:not([hidden]) hr:first-child')
.then(this.next);
},
function(result) {
checkIfNoErrorsOccured(this.next);
}
]);
}
// Exports test functions.
testcase.requestMount = requestMount;
})();
......@@ -24,6 +24,7 @@
"file_manager/open_image_files.js",
"file_manager/open_video_files.js",
"file_manager/open_zip_files.js",
"file_manager/providers.js",
"file_manager/restore_geometry.js",
"file_manager/restore_prefs.js",
"file_manager/share_dialog.js",
......
// Copyright 2015 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';
var dialogSettings = {};
chrome.fileSystemProvider.onGetMetadataRequested.addListener(
function(options, onSuccess, onError) {
onSuccess({
isDirectory: true,
name: '',
size: 0,
modificationTime: new Date()
});
});
chrome.fileSystemProvider.onReadDirectoryRequested.addListener(
function(options, onSuccess, onError) {
onSuccess([], false /* hasMore */);
});
chrome.fileSystemProvider.onMountRequested.addListener(
function(onSuccess, onError) {
chrome.fileSystemProvider.getAll(function(mounted) {
var index = mounted.length + 1;
chrome.fileSystemProvider.mount({
fileSystemId: 'test-fs-' + index,
displayName: 'Test (' + index + ')'
});
});
});
chrome.fileSystemProvider.onUnmountRequested.addListener(
function(options, onSuccess, onError) {
chrome.fileSystemProvider.unmount(
{
fileSystemId: options.fileSystemId
},
function() {
if (chrome.runtime.lastError)
onError(chrome.runtime.lastError.message);
else
onSuccess();
});
});
{
// chrome-extension://pkplfbidichfdicaijlchgnapepdginl
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtDfX9dHNh948bt00YhZBm3P6E5QLaOt+v8kXVtibQfiPtOD2FTScB/f0wX/EQWVO7BkaSOsRkTPcPIgocyMPYr2FLgqGLFlYT9nQpKJZUFNF5oJ5rG6Nv7ppf4zEB3j6da1IBRTz2yOZ+6O1TMZxol/V62/QcqrJeggsHTEPGLdr9Ua4b1Ka0xKJnJngZljsbw93FI1o+P9dAh5BS6wTPiZI/vmJVjvMTkSTnaZ3n9Go2t7A0XLcSxLcVyuLAd2mAvSN0mIviOukdM66wr7llif71nKuUt+4qvlr/r9HfwzN6pA4jkwhtS1UD+3CmB+wsHwsnohNcuu4FIQ6rgq/7QIDAQAB",
"name": "Testing Provider",
"version": "0.1",
"manifest_version": 2,
"description": "Testing Provider",
"permissions": [
"fileSystemProvider"
],
"file_system_provider_capabilities": {
"source": "network",
"multiple_mounts": false
},
"background": {
"scripts": ["background.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