Commit 6a73e559 authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

Clarify the "isInGuestMode" test extension command

Add FileManageBrowserTestBase private helper routines: IsGuestModeTest
and IsIncognitoModeTest to return true when the test extension browser
test has that GetGuestMode(). Use the helpers everywhere.

The "isInGuestMode" command actually wants to know if the test runs in
guest or incognito mode, or not. Write that out explicitly in its code
and add LOG(INFO) and ASSERT_EQ() for even more explanation.

Move "isInGuestMode" command so it's the first, move "getTestCaseName"
command so it's third, to match the call order the test extensions use
to call them: isInGuestMode, getRootPaths, getTestCaseName [1].

Minor change to getRootPaths: call the variable downloads_root.

[1] The test extensions call in this order always and once these three
are done, the test extensions start running the test case. Another way
to think about it is: these three commands are preliminary set-up that
every Files.app browser test case requires. All remaining commands are
specific to the current test case.

Bug: 833834
Change-Id: Ida01b88e745df6bf4b760aa421d36c5d8e872ecd
Reviewed-on: https://chromium-review.googlesource.com/1043672Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Reviewed-by: default avatarStuart Langley <slangley@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#556362}
parent fa744efa
......@@ -543,13 +543,13 @@ void FileManagerBrowserTestBase::SetUp() {
void FileManagerBrowserTestBase::SetUpCommandLine(
base::CommandLine* command_line) {
if (GetGuestMode() == IN_GUEST_MODE) {
if (IsGuestModeTest()) {
command_line->AppendSwitch(chromeos::switches::kGuestSession);
command_line->AppendSwitchNative(chromeos::switches::kLoginUser, "");
command_line->AppendSwitch(switches::kIncognito);
}
if (GetGuestMode() == IN_INCOGNITO) {
if (IsIncognitoModeTest()) {
command_line->AppendSwitch(switches::kIncognito);
}
......@@ -561,7 +561,7 @@ void FileManagerBrowserTestBase::SetUpInProcessBrowserTestFixture() {
local_volume_.reset(new DownloadsTestVolume);
if (GetGuestMode() != IN_GUEST_MODE) {
if (!IsGuestModeTest()) {
create_drive_integration_service_ =
base::Bind(&FileManagerBrowserTestBase::CreateDriveIntegrationService,
base::Unretained(this));
......@@ -577,7 +577,7 @@ void FileManagerBrowserTestBase::SetUpOnMainThread() {
CHECK(local_volume_->Mount(profile()));
if (GetGuestMode() != IN_GUEST_MODE) {
if (!IsGuestModeTest()) {
// Start the embedded test server to serve the mocked share dialog.
CHECK(embedded_test_server()->Start());
const GURL share_url_base(embedded_test_server()->GetURL(
......@@ -671,29 +671,36 @@ void FileManagerBrowserTestBase::OnCommand(const std::string& name,
std::string* output) {
base::ScopedAllowBlockingForTesting allow_blocking;
if (name == "getTestName") {
// Obtain the test case name.
*output = GetTestCaseName();
if (name == "isInGuestMode") {
// Obtain if the test runs in guest or incognito mode, or not.
if (IsGuestModeTest() || IsIncognitoModeTest()) {
LOG(INFO) << GetTestCaseName() << " isInGuestMode: true";
*output = "true";
} else {
ASSERT_EQ(NOT_IN_GUEST_MODE, GetGuestMode());
*output = "false";
}
return;
}
if (name == "getRootPaths") {
// Obtain the root paths.
const auto downloads = util::GetDownloadsMountPointName(profile());
const auto downloads_root = util::GetDownloadsMountPointName(profile());
const auto drive = drive::util::GetDriveMountPointPath(profile());
base::DictionaryValue dictionary;
auto drive_root = drive.BaseName().AsUTF8Unsafe().append("/root");
dictionary.SetString("drive", "/" + drive_root);
dictionary.SetString("downloads", "/" + downloads);
dictionary.SetString("downloads", "/" + downloads_root);
base::JSONWriter::Write(dictionary, output);
return;
}
if (name == "isInGuestMode") {
// Obtain whether the test is in guest mode or not.
*output = GetGuestMode() != NOT_IN_GUEST_MODE ? "true" : "false";
if (name == "getTestName") {
// Obtain the test case name.
*output = GetTestCaseName();
return;
}
......
......@@ -55,6 +55,12 @@ class FileManagerBrowserTestBase : public ExtensionApiTest {
virtual const char* GetTestExtensionManifestName() const = 0;
private:
// Returns true if the test requires incognito mode.
bool IsIncognitoModeTest() const { return GetGuestMode() == IN_INCOGNITO; }
// Returns true if the test requires in guest mode.
bool IsGuestModeTest() const { return GetGuestMode() == IN_GUEST_MODE; }
// Called during setup if needed, to create a drive integration service for
// the given |profile|. Caller owns the return result.
drive::DriveIntegrationService* CreateDriveIntegrationService(
......
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