#include "base/strings/string_piece.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/drive/drive_integration_service.h"
#include "chrome/browser/chromeos/drive/file_system_interface.h"
+#include "chrome/browser/chromeos/drive/test_util.h"
#include "chrome/browser/chromeos/file_manager/app_id.h"
#include "chrome/browser/chromeos/file_manager/drive_test_util.h"
#include "chrome/browser/chromeos/file_manager/path_util.h"
#include "chrome/browser/drive/fake_drive_service.h"
#include "chrome/browser/extensions/component_loader.h"
#include "chrome/browser/extensions/extension_apitest.h"
+#include "chrome/browser/notifications/notification.h"
+#include "chrome/browser/notifications/notification_ui_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
#include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
DownloadsTestVolume() : LocalTestVolume("Downloads") {}
virtual ~DownloadsTestVolume() {}
- virtual bool Mount(Profile* profile) OVERRIDE {
+ virtual bool Mount(Profile* profile) override {
return CreateRootDirectory(profile) &&
VolumeManager::Get(profile)
->RegisterDownloadsDirectoryForTesting(root_path());
return true;
}
- virtual bool Mount(Profile* profile) OVERRIDE {
+ virtual bool Mount(Profile* profile) override {
if (!CreateRootDirectory(profile))
return false;
storage::ExternalMountPoints* const mount_points =
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details) OVERRIDE {
+ const content::NotificationDetails& details) override {
Message entry;
entry.type = type;
entry.message = type != extensions::NOTIFICATION_EXTENSION_TEST_PASSED
// The base test class.
class FileManagerBrowserTestBase : public ExtensionApiTest {
protected:
- virtual void SetUpInProcessBrowserTestFixture() OVERRIDE;
+ virtual void SetUpInProcessBrowserTestFixture() override;
- virtual void SetUpOnMainThread() OVERRIDE;
+ virtual void SetUpOnMainThread() override;
// Adds an incognito and guest-mode flags for tests in the guest mode.
- virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
+ virtual void SetUpCommandLine(CommandLine* command_line) override;
// Loads our testing extension and sends it a string identifying the current
// test.
}
virtual GuestMode GetGuestModeParam() const = 0;
virtual const char* GetTestCaseNameParam() const = 0;
- virtual std::string OnMessage(const std::string& name,
- const base::Value* value);
+ virtual void OnMessage(const std::string& name,
+ const base::DictionaryValue& value,
+ std::string* output);
scoped_ptr<LocalTestVolume> local_volume_;
linked_ptr<DriveTestVolume> drive_volume_;
drive_volume_->ConfigureShareUrlBase(share_url_base);
test_util::WaitUntilDriveMountPointIsAdded(profile());
}
+
+ net::NetworkChangeNotifier::SetTestNotificationsOnly(true);
}
void FileManagerBrowserTestBase::SetUpCommandLine(CommandLine* command_line) {
!message_dictionary->GetString("name", &name))
continue;
- entry.function->Reply(OnMessage(name, value.get()));
+ std::string output;
+ OnMessage(name, *message_dictionary, &output);
+ if (HasFatalFailure())
+ break;
+
+ entry.function->Reply(output);
}
}
-std::string FileManagerBrowserTestBase::OnMessage(const std::string& name,
- const base::Value* value) {
+void FileManagerBrowserTestBase::OnMessage(const std::string& name,
+ const base::DictionaryValue& value,
+ std::string* output) {
if (name == "getTestName") {
// Pass the test case name.
- return GetTestCaseNameParam();
- } else if (name == "getRootPaths") {
+ *output = GetTestCaseNameParam();
+ return;
+ }
+
+ if (name == "getRootPaths") {
// Pass the root paths.
const scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue());
res->SetString("downloads",
res->SetString("drive",
"/" + drive::util::GetDriveMountPointPath(profile()
).BaseName().AsUTF8Unsafe() + "/root");
- std::string jsonString;
- base::JSONWriter::Write(res.get(), &jsonString);
- return jsonString;
- } else if (name == "isInGuestMode") {
+ base::JSONWriter::Write(res.get(), output);
+ return;
+ }
+
+ if (name == "isInGuestMode") {
// Obtain whether the test is in guest mode or not.
- return GetGuestModeParam() != NOT_IN_GUEST_MODE ? "true" : "false";
- } else if (name == "getCwsWidgetContainerMockUrl") {
+ *output = GetGuestModeParam() != NOT_IN_GUEST_MODE ? "true" : "false";
+ return;
+ }
+
+ if (name == "getCwsWidgetContainerMockUrl") {
// Obtain whether the test is in guest mode or not.
const GURL url = embedded_test_server()->GetURL(
"/chromeos/file_manager/cws_container_mock/index.html");
const scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue());
res->SetString("url", url.spec());
res->SetString("origin", origin);
- std::string jsonString;
- base::JSONWriter::Write(res.get(), &jsonString);
- return jsonString;
- } else if (name == "addEntries") {
+ base::JSONWriter::Write(res.get(), output);
+ return;
+ }
+
+ if (name == "addEntries") {
// Add entries to the specified volume.
base::JSONValueConverter<AddEntriesMessage> add_entries_message_converter;
AddEntriesMessage message;
- if (!add_entries_message_converter.Convert(*value, &message))
- return "onError";
+ ASSERT_TRUE(add_entries_message_converter.Convert(value, &message));
+
for (size_t i = 0; i < message.entries.size(); ++i) {
switch (message.volume) {
case LOCAL_VOLUME:
break;
}
}
- return "onEntryAdded";
- } else if (name == "mountFakeUsb") {
+
+ return;
+ }
+
+ if (name == "mountFakeUsb") {
usb_volume_.reset(new FakeTestVolume("fake-usb",
VOLUME_TYPE_REMOVABLE_DISK_PARTITION,
chromeos::DEVICE_TYPE_USB));
usb_volume_->Mount(profile());
- return "true";
- } else if (name == "mountFakeMtp") {
+ return;
+ }
+
+ if (name == "mountFakeMtp") {
mtp_volume_.reset(new FakeTestVolume("fake-mtp",
VOLUME_TYPE_MTP,
chromeos::DEVICE_TYPE_UNKNOWN));
- if (!mtp_volume_->PrepareTestEntries(profile()))
- return "false";
+ ASSERT_TRUE(mtp_volume_->PrepareTestEntries(profile()));
+
mtp_volume_->Mount(profile());
- return "true";
+ return;
+ }
+
+ if (name == "useCellularNetwork") {
+ net::NetworkChangeNotifier::NotifyObserversOfConnectionTypeChangeForTests(
+ net::NetworkChangeNotifier::CONNECTION_3G);
+ return;
}
- return "unknownMessage";
+
+ if (name == "clickNotificationButton") {
+ std::string extension_id;
+ std::string notification_id;
+ int index;
+ ASSERT_TRUE(value.GetString("extensionId", &extension_id));
+ ASSERT_TRUE(value.GetString("notificationId", ¬ification_id));
+ ASSERT_TRUE(value.GetInteger("index", &index));
+
+ const std::string delegate_id = extension_id + "-" + notification_id;
+ const Notification* notification = g_browser_process->
+ notification_ui_manager()->FindById(delegate_id, profile());
+ ASSERT_TRUE(notification);
+
+ notification->delegate()->ButtonClick(index);
+ return;
+ }
+
+ FAIL() << "Unknown test message: " << name;
}
drive::DriveIntegrationService*
class FileManagerBrowserTest :
public FileManagerBrowserTestBase,
public ::testing::WithParamInterface<TestParameter> {
- virtual GuestMode GetGuestModeParam() const OVERRIDE {
+ virtual GuestMode GetGuestModeParam() const override {
return std::tr1::get<0>(GetParam());
}
- virtual const char* GetTestCaseNameParam() const OVERRIDE {
+ virtual const char* GetTestCaseNameParam() const override {
return std::tr1::get<1>(GetParam());
}
};
INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator)
// Slow tests are disabled on debug build. http://crbug.com/327719
-#if !defined(NDEBUG)
+// Fails on official build. http://crbug.com/429294
+#if !defined(NDEBUG) || defined(OFFICIAL_BUILD)
#define MAYBE_FileDisplay DISABLED_FileDisplay
#else
#define MAYBE_FileDisplay FileDisplay
TestParameter(NOT_IN_GUEST_MODE, "zipOpenDrive")));
// Slow tests are disabled on debug build. http://crbug.com/327719
-#if !defined(NDEBUG)
+// Fails on official build. http://crbug.com/429294
+#if !defined(NDEBUG) || defined(OFFICIAL_BUILD)
#define MAYBE_OpenVideoFiles DISABLED_OpenVideoFiles
#else
#define MAYBE_OpenVideoFiles OpenVideoFiles
TestParameter(NOT_IN_GUEST_MODE, "videoOpenDrive")));
// Slow tests are disabled on debug build. http://crbug.com/327719
-#if !defined(NDEBUG)
+// Fails on official build. http://crbug.com/429294
+#if !defined(NDEBUG) || defined(OFFICIAL_BUILD)
#define MAYBE_OpenAudioFiles DISABLED_OpenAudioFiles
#else
#define MAYBE_OpenAudioFiles OpenAudioFiles
"createNewFolderDrive")));
// Slow tests are disabled on debug build. http://crbug.com/327719
-#if !defined(NDEBUG)
+// Fails on official build. http://crbug.com/429294
+#if !defined(NDEBUG) || defined(OFFICIAL_BUILD)
#define MAYBE_KeyboardOperations DISABLED_KeyboardOperations
#else
#define MAYBE_KeyboardOperations KeyboardOperations
TestParameter(NOT_IN_GUEST_MODE, "keyboardCopyDrive"),
TestParameter(IN_GUEST_MODE, "renameFileDownloads"),
TestParameter(NOT_IN_GUEST_MODE, "renameFileDownloads"),
- TestParameter(NOT_IN_GUEST_MODE, "renameFileDrive")));
+ TestParameter(NOT_IN_GUEST_MODE, "renameFileDrive"),
+ TestParameter(IN_GUEST_MODE,
+ "renameNewDirectoryDownloads"),
+ TestParameter(NOT_IN_GUEST_MODE,
+ "renameNewDirectoryDownloads"),
+ TestParameter(NOT_IN_GUEST_MODE,
+ "renameNewDirectoryDrive")));
// Slow tests are disabled on debug build. http://crbug.com/327719
-#if !defined(NDEBUG)
+// Fails on official build. http://crbug.com/429294
+#if !defined(NDEBUG) || defined(OFFICIAL_BUILD)
#define MAYBE_DriveSpecific DISABLED_DriveSpecific
#else
#define MAYBE_DriveSpecific DriveSpecific
WRAPPED_INSTANTIATE_TEST_CASE_P(
MAYBE_DriveSpecific,
FileManagerBrowserTest,
- ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "openSidebarRecent"),
- TestParameter(NOT_IN_GUEST_MODE, "openSidebarOffline"),
- TestParameter(NOT_IN_GUEST_MODE,
- "openSidebarSharedWithMe"),
- TestParameter(NOT_IN_GUEST_MODE, "autocomplete")));
+ ::testing::Values(
+ TestParameter(NOT_IN_GUEST_MODE, "openSidebarRecent"),
+ TestParameter(NOT_IN_GUEST_MODE, "openSidebarOffline"),
+ TestParameter(NOT_IN_GUEST_MODE, "openSidebarSharedWithMe"),
+ TestParameter(NOT_IN_GUEST_MODE, "autocomplete"),
+ TestParameter(NOT_IN_GUEST_MODE, "pinFileOnMobileNetwork")));
// Slow tests are disabled on debug build. http://crbug.com/327719
-#if !defined(NDEBUG)
+// Fails on official build. http://crbug.com/429294
+#if !defined(NDEBUG) || defined(OFFICIAL_BUILD)
#define MAYBE_Transfer DISABLED_Transfer
#else
#define MAYBE_Transfer Transfer
TestParameter(NOT_IN_GUEST_MODE, "transferFromOfflineToDrive")));
// Slow tests are disabled on debug build. http://crbug.com/327719
-#if !defined(NDEBUG)
+// Fails on official build. http://crbug.com/429294
+#if !defined(NDEBUG) || defined(OFFICIAL_BUILD)
#define MAYBE_RestorePrefs DISABLED_RestorePrefs
#else
#define MAYBE_RestorePrefs RestorePrefs
// Slow tests are disabled on debug build. http://crbug.com/327719
#if !defined(NDEBUG)
+#define MAYBE_GenericTask DISABLED_GenericTask
+#else
+#define MAYBE_GenericTask GenericTask
+#endif
+WRAPPED_INSTANTIATE_TEST_CASE_P(
+ MAYBE_GenericTask,
+ FileManagerBrowserTest,
+ ::testing::Values(
+ TestParameter(NOT_IN_GUEST_MODE, "genericTaskIsNotExecuted"),
+ TestParameter(NOT_IN_GUEST_MODE, "genericAndNonGenericTasksAreMixed")));
+
+// Slow tests are disabled on debug build. http://crbug.com/327719
+#if !defined(NDEBUG)
#define MAYBE_FolderShortcuts DISABLED_FolderShortcuts
#else
#define MAYBE_FolderShortcuts FolderShortcuts
::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "thumbnailsDownloads"),
TestParameter(IN_GUEST_MODE, "thumbnailsDownloads")));
-#if !defined(NDEBUG)
+// Fails on official build. http://crbug.com/429294
+#if !defined(NDEBUG) || defined(OFFICIAL_BUILD)
#define MAYBE_OpenFileDialog DISABLED_OpenFileDialog
#else
#define MAYBE_OpenFileDialog OpenFileDialog
TestParameter(IN_INCOGNITO,
"openFileDialogOnDownloads"),
TestParameter(IN_INCOGNITO,
- "openFileDialogOnDrive")));
+ "openFileDialogOnDrive"),
+ TestParameter(NOT_IN_GUEST_MODE,
+ "unloadFileDialog")));
// Slow tests are disabled on debug build. http://crbug.com/327719
#if !defined(NDEBUG)
class MultiProfileFileManagerBrowserTest : public FileManagerBrowserTestBase {
protected:
// Enables multi-profiles.
- virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ virtual void SetUpCommandLine(CommandLine* command_line) override {
FileManagerBrowserTestBase::SetUpCommandLine(command_line);
// Logs in to a dummy profile (For making MultiProfileWindowManager happy;
// browser test creates a default window and the manager tries to assign a
}
// Logs in to the primary profile of this test.
- virtual void SetUpOnMainThread() OVERRIDE {
+ virtual void SetUpOnMainThread() override {
const TestAccountInfo& info = kTestAccounts[PRIMARY_ACCOUNT_INDEX];
AddUser(info, true);
}
// Returns primary profile (if it is already created.)
- virtual Profile* profile() OVERRIDE {
+ virtual Profile* profile() override {
Profile* const profile = chromeos::ProfileHelper::GetProfileByUserIdHash(
kTestAccounts[PRIMARY_ACCOUNT_INDEX].hash);
return profile ? profile : FileManagerBrowserTestBase::profile();
}
private:
- virtual GuestMode GetGuestModeParam() const OVERRIDE {
+ virtual GuestMode GetGuestModeParam() const override {
return NOT_IN_GUEST_MODE;
}
- virtual const char* GetTestCaseNameParam() const OVERRIDE {
+ virtual const char* GetTestCaseNameParam() const override {
return test_case_name_.c_str();
}
- virtual std::string OnMessage(const std::string& name,
- const base::Value* value) OVERRIDE {
- if (name == "addAllUsers") {
- AddAllUsers();
- return "true";
- } else if (name == "getWindowOwnerId") {
- chrome::MultiUserWindowManager* const window_manager =
- chrome::MultiUserWindowManager::GetInstance();
- extensions::AppWindowRegistry* const app_window_registry =
- extensions::AppWindowRegistry::Get(profile());
- DCHECK(window_manager);
- DCHECK(app_window_registry);
-
- const extensions::AppWindowRegistry::AppWindowList& list =
- app_window_registry->GetAppWindowsForApp(
- file_manager::kFileManagerAppId);
- return list.size() == 1u ?
- window_manager->GetUserPresentingWindow(
- list.front()->GetNativeWindow()) : "";
- }
- return FileManagerBrowserTestBase::OnMessage(name, value);
- }
-
std::string test_case_name_;
};
// Slow tests are disabled on debug build. http://crbug.com/327719
-#if !defined(NDEBUG)
+// Fails on official build. http://crbug.com/429294
+#if !defined(NDEBUG) || defined(OFFICIAL_BUILD)
#define MAYBE_PRE_BasicDownloads DISABLED_PRE_BasicDownloads
#define MAYBE_BasicDownloads DISABLED_BasicDownloads
#else
}
// Slow tests are disabled on debug build. http://crbug.com/327719
-#if !defined(NDEBUG)
+// Fails on official build. http://crbug.com/429294
+#if !defined(NDEBUG) || defined(OFFICIAL_BUILD)
#define MAYBE_PRE_BasicDrive DISABLED_PRE_BasicDrive
#define MAYBE_BasicDrive DISABLED_BasicDrive
#else
template<GuestMode M>
class GalleryBrowserTestBase : public FileManagerBrowserTestBase {
public:
- virtual GuestMode GetGuestModeParam() const OVERRIDE { return M; }
- virtual const char* GetTestCaseNameParam() const OVERRIDE {
+ virtual GuestMode GetGuestModeParam() const override { return M; }
+ virtual const char* GetTestCaseNameParam() const override {
return test_case_name_.c_str();
}
protected:
- virtual void SetUp() OVERRIDE {
+ virtual void SetUp() override {
AddScript("common/test_util_common.js");
AddScript("gallery/test_util.js");
FileManagerBrowserTestBase::SetUp();
}
- virtual std::string OnMessage(const std::string& name,
- const base::Value* value) OVERRIDE;
+ virtual void OnMessage(const std::string& name,
+ const base::DictionaryValue& value,
+ std::string* output) override;
- virtual const char* GetTestManifestName() const OVERRIDE {
+ virtual const char* GetTestManifestName() const override {
return "gallery_test_manifest.json";
}
std::string test_case_name_;
};
-template<GuestMode M>
-std::string GalleryBrowserTestBase<M>::OnMessage(const std::string& name,
- const base::Value* value) {
+template <GuestMode M>
+void GalleryBrowserTestBase<M>::OnMessage(const std::string& name,
+ const base::DictionaryValue& value,
+ std::string* output) {
if (name == "getScripts") {
std::string jsonString;
- base::JSONWriter::Write(&scripts_, &jsonString);
- return jsonString;
+ base::JSONWriter::Write(&scripts_, output);
+ return;
}
- return FileManagerBrowserTestBase::OnMessage(name, value);
+
+ FileManagerBrowserTestBase::OnMessage(name, value, output);
}
typedef GalleryBrowserTestBase<NOT_IN_GUEST_MODE> GalleryBrowserTest;
template<GuestMode M>
class VideoPlayerBrowserTestBase : public FileManagerBrowserTestBase {
public:
- virtual GuestMode GetGuestModeParam() const OVERRIDE { return M; }
- virtual const char* GetTestCaseNameParam() const OVERRIDE {
+ virtual GuestMode GetGuestModeParam() const override { return M; }
+ virtual const char* GetTestCaseNameParam() const override {
return test_case_name_.c_str();
}
protected:
- virtual void SetUp() OVERRIDE {
+ virtual void SetUp() override {
AddScript("common/test_util_common.js");
AddScript("video_player/test_util.js");
FileManagerBrowserTestBase::SetUp();
}
- virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ virtual void SetUpCommandLine(CommandLine* command_line) override {
command_line->AppendSwitch(
chromeos::switches::kEnableVideoPlayerChromecastSupport);
FileManagerBrowserTestBase::SetUpCommandLine(command_line);
}
- virtual std::string OnMessage(const std::string& name,
- const base::Value* value) OVERRIDE;
+ virtual void OnMessage(const std::string& name,
+ const base::DictionaryValue& value,
+ std::string* output) override;
- virtual const char* GetTestManifestName() const OVERRIDE {
+ virtual const char* GetTestManifestName() const override {
return "video_player_test_manifest.json";
}
std::string test_case_name_;
};
-template<GuestMode M>
-std::string VideoPlayerBrowserTestBase<M>::OnMessage(const std::string& name,
- const base::Value* value) {
+template <GuestMode M>
+void VideoPlayerBrowserTestBase<M>::OnMessage(
+ const std::string& name,
+ const base::DictionaryValue& value,
+ std::string* output) {
if (name == "getScripts") {
std::string jsonString;
- base::JSONWriter::Write(&scripts_, &jsonString);
- return jsonString;
+ base::JSONWriter::Write(&scripts_, output);
+ return;
}
- return FileManagerBrowserTestBase::OnMessage(name, value);
+
+ FileManagerBrowserTestBase::OnMessage(name, value, output);
}
typedef VideoPlayerBrowserTestBase<NOT_IN_GUEST_MODE> VideoPlayerBrowserTest;