1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601
|
// Copyright 2014 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.
#include "base/callback.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/location.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/path_service.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/apps/platform_apps/app_browsertest_util.h"
#include "chrome/browser/chromeos/drive/drive_integration_service.h"
#include "chrome/browser/chromeos/drive/drivefs_test_support.h"
#include "chrome/browser/chromeos/drive/file_system_util.h"
#include "chrome/browser/chromeos/file_manager/volume_manager.h"
#include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/extensions/api/file_system/consent_provider.h"
#include "chrome/browser/extensions/component_loader.h"
#include "chrome/common/chrome_paths.h"
#include "chromeos/constants/chromeos_features.h"
#include "components/drive/chromeos/file_system_interface.h"
#include "components/drive/service/fake_drive_service.h"
#include "components/user_manager/scoped_user_manager.h"
#include "content/public/test/test_utils.h"
#include "extensions/browser/api/file_system/file_system_api.h"
#include "extensions/browser/event_router.h"
#include "extensions/common/api/file_system.h"
#include "extensions/common/switches.h"
#include "google_apis/drive/base_requests.h"
#include "google_apis/drive/drive_api_parser.h"
#include "google_apis/drive/test_util.h"
#include "storage/browser/fileapi/external_mount_points.h"
#include "ui/base/ui_base_types.h"
// TODO(michaelpg): Port these tests to app_shell: crbug.com/505926.
using file_manager::VolumeManager;
using file_manager::VolumeType;
namespace extensions {
namespace {
// Mount point names for chrome.fileSystem.requestFileSystem() tests.
const char kWritableMountPointName[] = "writable";
const char kReadOnlyMountPointName[] = "read-only";
const char kDownloadsMountPointName[] = "downloads";
// Child directory created in each of the mount points.
const char kChildDirectory[] = "child-dir";
// ID of a testing extension.
const char kTestingExtensionId[] = "pkplfbidichfdicaijlchgnapepdginl";
void IgnoreDriveEntryResult(google_apis::DriveApiErrorCode error,
std::unique_ptr<google_apis::FileResource> entry) {}
} // namespace
// Skips the user consent dialog for chrome.fileSystem.requestFileSystem() and
// simulates clicking of the specified dialog button.
class ScopedSkipRequestFileSystemDialog {
public:
explicit ScopedSkipRequestFileSystemDialog(ui::DialogButton button) {
file_system_api::ConsentProviderDelegate::SetAutoDialogButtonForTest(
button);
}
~ScopedSkipRequestFileSystemDialog() {
file_system_api::ConsentProviderDelegate::SetAutoDialogButtonForTest(
ui::DIALOG_BUTTON_NONE);
}
private:
DISALLOW_COPY_AND_ASSIGN(ScopedSkipRequestFileSystemDialog);
};
// Observers adding a listener to the |event_name| event by |extension|, and
// then fires the |callback|.
class ScopedAddListenerObserver : public EventRouter::Observer {
public:
ScopedAddListenerObserver(Profile* profile,
const std::string& event_name,
const std::string& extension_id,
base::OnceClosure callback)
: extension_id_(extension_id),
callback_(std::move(callback)),
event_router_(EventRouter::EventRouter::Get(profile)) {
DCHECK(profile);
event_router_->RegisterObserver(this, event_name);
}
~ScopedAddListenerObserver() override {
event_router_->UnregisterObserver(this);
}
// EventRouter::Observer overrides.
void OnListenerAdded(const EventListenerInfo& details) override {
// Call the callback only once, as the listener may be added multiple times.
if (details.extension_id != extension_id_ || !callback_)
return;
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
std::move(callback_));
}
private:
const std::string extension_id_;
base::OnceClosure callback_;
EventRouter* const event_router_;
DISALLOW_COPY_AND_ASSIGN(ScopedAddListenerObserver);
};
// This class contains chrome.filesystem API test specific to Chrome OS, namely,
// the integrated Google Drive support.
class FileSystemApiTestForDrive : public PlatformAppBrowserTest {
public:
FileSystemApiTestForDrive() {}
bool SetUpUserDataDirectory() override {
return drive::SetUpUserDataDirectoryForDriveFsTest();
}
// Sets up fake Drive service for tests (this has to be injected before the
// real DriveIntegrationService instance is created.)
void SetUpInProcessBrowserTestFixture() override {
PlatformAppBrowserTest::SetUpInProcessBrowserTestFixture();
extensions::ComponentLoader::EnableBackgroundExtensionsForTesting();
ASSERT_TRUE(test_cache_root_.CreateUniqueTempDir());
create_drive_integration_service_ =
base::Bind(&FileSystemApiTestForDrive::CreateDriveIntegrationService,
base::Unretained(this));
service_factory_for_test_.reset(
new drive::DriveIntegrationServiceFactory::ScopedFactoryForTest(
&create_drive_integration_service_));
}
// Ensure the fake service's data is fetch in the local file system. This is
// necessary because the fetch starts lazily upon the first read operation.
void SetUpOnMainThread() override {
PlatformAppBrowserTest::SetUpOnMainThread();
if (!base::FeatureList::IsEnabled(chromeos::features::kDriveFs)) {
std::unique_ptr<drive::ResourceEntry> entry;
drive::FileError error = drive::FILE_ERROR_FAILED;
integration_service_->file_system()->GetResourceEntry(
base::FilePath::FromUTF8Unsafe("drive/root"), // whatever
google_apis::test_util::CreateCopyResultCallback(&error, &entry));
content::RunAllTasksUntilIdle();
ASSERT_EQ(drive::FILE_ERROR_OK, error);
}
}
void TearDown() override {
FileSystemChooseEntryFunction::StopSkippingPickerForTest();
PlatformAppBrowserTest::TearDown();
};
base::FilePath GetDriveMountPoint() {
if (base::FeatureList::IsEnabled(chromeos::features::kDriveFs)) {
return drivefs_mount_point_;
} else {
return drive::util::GetDriveMountPointPath(browser()->profile());
}
}
private:
drive::DriveIntegrationService* CreateDriveIntegrationService(
Profile* profile) {
// Ignore signin and lock screen apps profile.
if (profile->GetPath() == chromeos::ProfileHelper::GetSigninProfileDir() ||
profile->GetPath() ==
chromeos::ProfileHelper::GetLockScreenAppProfilePath()) {
return nullptr;
}
// FileSystemApiTestForDrive doesn't expect that several user profiles could
// exist simultaneously.
DCHECK(!fake_drive_service_);
fake_drive_service_ = new drive::FakeDriveService;
CHECK(drivefs_root_.CreateUniqueTempDir());
drivefs_mount_point_ = drivefs_root_.GetPath().Append("drive-user");
fake_drivefs_helper_ = std::make_unique<drive::FakeDriveFsHelper>(
profile, drivefs_mount_point_);
SetUpTestFileHierarchy();
integration_service_ = new drive::DriveIntegrationService(
profile, nullptr, fake_drive_service_, "", test_cache_root_.GetPath(),
nullptr, fake_drivefs_helper_->CreateFakeDriveFsListenerFactory());
return integration_service_;
}
void SetUpTestFileHierarchy() {
CHECK(base::CreateDirectory(drivefs_mount_point_.Append("root")));
const std::string root = fake_drive_service_->GetRootResourceId();
AddTestFile("open_existing.txt", "Can you see me?", root);
AddTestFile("open_existing1.txt", "Can you see me?", root);
AddTestFile("open_existing2.txt", "Can you see me?", root);
AddTestFile("save_existing.txt", "Can you see me?", root);
const char kSubdirResourceId[] = "subdir_resource_id";
AddTestDirectory(kSubdirResourceId, "subdir", root);
AddTestFile("open_existing.txt", "Can you see me?", kSubdirResourceId);
}
void AddTestFile(const std::string& title,
const std::string& data,
const std::string& parent_id) {
fake_drive_service_->AddNewFile("text/plain", data, parent_id, title, false,
base::Bind(&IgnoreDriveEntryResult));
base::FilePath parent_path = drivefs_mount_point_.Append("root");
if (parent_id == "subdir_resource_id") {
parent_path = parent_path.Append("subdir");
}
CHECK(base::WriteFile(parent_path.Append(title), data.data(), data.size()));
}
void AddTestDirectory(const std::string& resource_id,
const std::string& title,
const std::string& parent_id) {
fake_drive_service_->AddNewDirectoryWithResourceId(
resource_id, parent_id, title, drive::AddNewDirectoryOptions(),
base::Bind(&IgnoreDriveEntryResult));
CHECK(base::CreateDirectory(
drivefs_mount_point_.Append("root").Append(title)));
}
base::ScopedTempDir test_cache_root_;
base::ScopedTempDir drivefs_root_;
base::FilePath drivefs_mount_point_;
drive::FakeDriveService* fake_drive_service_ = nullptr;
std::unique_ptr<drive::FakeDriveFsHelper> fake_drivefs_helper_;
drive::DriveIntegrationService* integration_service_ = nullptr;
drive::DriveIntegrationServiceFactory::FactoryCallback
create_drive_integration_service_;
std::unique_ptr<drive::DriveIntegrationServiceFactory::ScopedFactoryForTest>
service_factory_for_test_;
};
// This class contains chrome.filesystem.requestFileSystem API tests.
class FileSystemApiTestForRequestFileSystem : public PlatformAppBrowserTest {
public:
FileSystemApiTestForRequestFileSystem() : fake_user_manager_(nullptr) {}
bool SetUpUserDataDirectory() override {
return drive::SetUpUserDataDirectoryForDriveFsTest();
}
void SetUpCommandLine(base::CommandLine* command_line) override {
PlatformAppBrowserTest::SetUpCommandLine(command_line);
command_line->AppendSwitchASCII(
extensions::switches::kWhitelistedExtensionID, kTestingExtensionId);
}
// Sets up fake Drive service for tests (this has to be injected before the
// real DriveIntegrationService instance is created.)
void SetUpInProcessBrowserTestFixture() override {
PlatformAppBrowserTest::SetUpInProcessBrowserTestFixture();
extensions::ComponentLoader::EnableBackgroundExtensionsForTesting();
create_drive_integration_service_ = base::BindRepeating(
&FileSystemApiTestForRequestFileSystem::CreateDriveIntegrationService,
base::Unretained(this));
service_factory_for_test_.reset(
new drive::DriveIntegrationServiceFactory::ScopedFactoryForTest(
&create_drive_integration_service_));
}
void SetUpOnMainThread() override {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
CreateTestingFileSystem(kWritableMountPointName,
file_manager::VOLUME_TYPE_TESTING,
false /* read_only */);
CreateTestingFileSystem(kReadOnlyMountPointName,
file_manager::VOLUME_TYPE_TESTING,
true /* read_only */);
CreateTestingFileSystem(kDownloadsMountPointName,
file_manager::VOLUME_TYPE_DOWNLOADS_DIRECTORY,
false /* read_only */);
PlatformAppBrowserTest::SetUpOnMainThread();
}
void TearDownOnMainThread() override {
PlatformAppBrowserTest::TearDownOnMainThread();
user_manager_enabler_.reset();
fake_user_manager_ = nullptr;
}
// Simulates mounting a removable volume.
void MountFakeVolume() {
VolumeManager* const volume_manager =
VolumeManager::Get(browser()->profile());
ASSERT_TRUE(volume_manager);
volume_manager->AddVolumeForTesting(
base::FilePath("/a/b/c"), file_manager::VOLUME_TYPE_TESTING,
chromeos::DEVICE_TYPE_UNKNOWN, false /* read_only */);
}
protected:
base::ScopedTempDir temp_dir_;
chromeos::FakeChromeUserManager* fake_user_manager_;
std::unique_ptr<user_manager::ScopedUserManager> user_manager_enabler_;
// Creates a testing file system in a testing directory.
void CreateTestingFileSystem(const std::string& mount_point_name,
VolumeType volume_type,
bool read_only) {
const base::FilePath mount_point_path =
temp_dir_.GetPath().Append(mount_point_name);
ASSERT_TRUE(base::CreateDirectory(mount_point_path));
ASSERT_TRUE(
base::CreateDirectory(mount_point_path.Append(kChildDirectory)));
ASSERT_TRUE(content::BrowserContext::GetMountPoints(browser()->profile())
->RegisterFileSystem(
mount_point_name, storage::kFileSystemTypeNativeLocal,
storage::FileSystemMountOption(), mount_point_path));
VolumeManager* const volume_manager =
VolumeManager::Get(browser()->profile());
ASSERT_TRUE(volume_manager);
volume_manager->AddVolumeForTesting(mount_point_path, volume_type,
chromeos::DEVICE_TYPE_UNKNOWN,
read_only);
}
// Simulates entering the kiosk session.
void EnterKioskSession() {
fake_user_manager_ = new chromeos::FakeChromeUserManager();
user_manager_enabler_ = std::make_unique<user_manager::ScopedUserManager>(
base::WrapUnique(fake_user_manager_));
const AccountId kiosk_app_account_id =
AccountId::FromUserEmail("kiosk@foobar.com");
fake_user_manager_->AddKioskAppUser(kiosk_app_account_id);
fake_user_manager_->LoginUser(kiosk_app_account_id);
}
private:
drive::DriveIntegrationService* CreateDriveIntegrationService(
Profile* profile) {
// Ignore signin and lock screen apps profile.
if (profile->GetPath() == chromeos::ProfileHelper::GetSigninProfileDir() ||
profile->GetPath() ==
chromeos::ProfileHelper::GetLockScreenAppProfilePath()) {
return nullptr;
}
CHECK(drivefs_root_.CreateUniqueTempDir());
fake_drivefs_helper_ = std::make_unique<drive::FakeDriveFsHelper>(
profile, drivefs_root_.GetPath().Append("drive-user"));
return new drive::DriveIntegrationService(
profile, nullptr, nullptr, "", {}, nullptr,
fake_drivefs_helper_->CreateFakeDriveFsListenerFactory());
}
base::ScopedTempDir drivefs_root_;
std::unique_ptr<drive::FakeDriveFsHelper> fake_drivefs_helper_;
drive::DriveIntegrationServiceFactory::FactoryCallback
create_drive_integration_service_;
std::unique_ptr<drive::DriveIntegrationServiceFactory::ScopedFactoryForTest>
service_factory_for_test_;
};
IN_PROC_BROWSER_TEST_F(FileSystemApiTestForDrive,
FileSystemApiOpenExistingFileTest) {
base::FilePath test_file =
GetDriveMountPoint().AppendASCII("root/open_existing.txt");
FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest(
&test_file);
ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/open_existing"))
<< message_;
}
IN_PROC_BROWSER_TEST_F(FileSystemApiTestForDrive,
FileSystemApiOpenExistingFileWithWriteTest) {
base::FilePath test_file =
GetDriveMountPoint().AppendASCII("root/open_existing.txt");
FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest(
&test_file);
ASSERT_TRUE(RunPlatformAppTest(
"api_test/file_system/open_existing_with_write")) << message_;
}
IN_PROC_BROWSER_TEST_F(FileSystemApiTestForDrive,
FileSystemApiOpenMultipleSuggested) {
base::FilePath test_file =
GetDriveMountPoint().AppendASCII("root/open_existing.txt");
ASSERT_TRUE(base::PathService::OverrideAndCreateIfNeeded(
chrome::DIR_USER_DOCUMENTS, test_file.DirName(), true, false));
FileSystemChooseEntryFunction::SkipPickerAndSelectSuggestedPathForTest();
ASSERT_TRUE(RunPlatformAppTest(
"api_test/file_system/open_multiple_with_suggested_name"))
<< message_;
}
IN_PROC_BROWSER_TEST_F(FileSystemApiTestForDrive,
FileSystemApiOpenMultipleExistingFilesTest) {
base::FilePath test_file1 =
GetDriveMountPoint().AppendASCII("root/open_existing1.txt");
base::FilePath test_file2 =
GetDriveMountPoint().AppendASCII("root/open_existing2.txt");
std::vector<base::FilePath> test_files;
test_files.push_back(test_file1);
test_files.push_back(test_file2);
FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathsForTest(
&test_files);
ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/open_multiple_existing"))
<< message_;
}
IN_PROC_BROWSER_TEST_F(FileSystemApiTestForDrive,
FileSystemApiOpenDirectoryTest) {
base::FilePath test_directory =
GetDriveMountPoint().AppendASCII("root/subdir");
FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest(
&test_directory);
ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/open_directory"))
<< message_;
}
#if defined(ADDRESS_SANITIZER)
// Flaky when run under ASan: crbug.com/499233.
#define MAYBE_FileSystemApiOpenDirectoryWithWriteTest \
DISABLED_FileSystemApiOpenDirectoryWithWriteTest
#else
#define MAYBE_FileSystemApiOpenDirectoryWithWriteTest \
FileSystemApiOpenDirectoryWithWriteTest
#endif
IN_PROC_BROWSER_TEST_F(FileSystemApiTestForDrive,
MAYBE_FileSystemApiOpenDirectoryWithWriteTest) {
base::FilePath test_directory =
GetDriveMountPoint().AppendASCII("root/subdir");
FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest(
&test_directory);
ASSERT_TRUE(
RunPlatformAppTest("api_test/file_system/open_directory_with_write"))
<< message_;
}
IN_PROC_BROWSER_TEST_F(FileSystemApiTestForDrive,
FileSystemApiOpenDirectoryWithoutPermissionTest) {
base::FilePath test_directory =
GetDriveMountPoint().AppendASCII("root/subdir");
FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest(
&test_directory);
ASSERT_TRUE(RunPlatformAppTest(
"api_test/file_system/open_directory_without_permission"))
<< message_;
}
IN_PROC_BROWSER_TEST_F(FileSystemApiTestForDrive,
FileSystemApiOpenDirectoryWithOnlyWritePermissionTest) {
base::FilePath test_directory =
GetDriveMountPoint().AppendASCII("root/subdir");
FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest(
&test_directory);
ASSERT_TRUE(RunPlatformAppTest(
"api_test/file_system/open_directory_with_only_write"))
<< message_;
}
IN_PROC_BROWSER_TEST_F(FileSystemApiTestForDrive,
FileSystemApiSaveNewFileTest) {
base::FilePath test_file =
GetDriveMountPoint().AppendASCII("root/save_new.txt");
FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest(
&test_file);
ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/save_new"))
<< message_;
}
IN_PROC_BROWSER_TEST_F(FileSystemApiTestForDrive,
FileSystemApiSaveExistingFileTest) {
base::FilePath test_file =
GetDriveMountPoint().AppendASCII("root/save_existing.txt");
FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest(
&test_file);
ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/save_existing"))
<< message_;
}
IN_PROC_BROWSER_TEST_F(FileSystemApiTestForDrive,
FileSystemApiSaveNewFileWithWriteTest) {
base::FilePath test_file =
GetDriveMountPoint().AppendASCII("root/save_new.txt");
FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest(
&test_file);
ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/save_new_with_write"))
<< message_;
}
IN_PROC_BROWSER_TEST_F(FileSystemApiTestForDrive,
FileSystemApiSaveExistingFileWithWriteTest) {
base::FilePath test_file =
GetDriveMountPoint().AppendASCII("root/save_existing.txt");
FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest(
&test_file);
ASSERT_TRUE(RunPlatformAppTest(
"api_test/file_system/save_existing_with_write")) << message_;
}
IN_PROC_BROWSER_TEST_F(FileSystemApiTestForRequestFileSystem, Background) {
EnterKioskSession();
ScopedSkipRequestFileSystemDialog dialog_skipper(ui::DIALOG_BUTTON_OK);
ASSERT_TRUE(
RunPlatformAppTest("api_test/file_system/request_file_system_background"))
<< message_;
}
IN_PROC_BROWSER_TEST_F(FileSystemApiTestForRequestFileSystem, ReadOnly) {
EnterKioskSession();
ScopedSkipRequestFileSystemDialog dialog_skipper(ui::DIALOG_BUTTON_OK);
ASSERT_TRUE(
RunPlatformAppTest("api_test/file_system/request_file_system_read_only"))
<< message_;
}
IN_PROC_BROWSER_TEST_F(FileSystemApiTestForRequestFileSystem, Writable) {
EnterKioskSession();
ScopedSkipRequestFileSystemDialog dialog_skipper(ui::DIALOG_BUTTON_OK);
ASSERT_TRUE(
RunPlatformAppTest("api_test/file_system/request_file_system_writable"))
<< message_;
}
IN_PROC_BROWSER_TEST_F(FileSystemApiTestForRequestFileSystem, UserReject) {
EnterKioskSession();
ScopedSkipRequestFileSystemDialog dialog_skipper(ui::DIALOG_BUTTON_CANCEL);
ASSERT_TRUE(RunPlatformAppTest(
"api_test/file_system/request_file_system_user_reject"))
<< message_;
}
IN_PROC_BROWSER_TEST_F(FileSystemApiTestForRequestFileSystem, NotKioskSession) {
ScopedSkipRequestFileSystemDialog dialog_skipper(ui::DIALOG_BUTTON_OK);
ASSERT_TRUE(RunPlatformAppTest(
"api_test/file_system/request_file_system_not_kiosk_session"))
<< message_;
}
IN_PROC_BROWSER_TEST_F(FileSystemApiTestForRequestFileSystem,
WhitelistedComponent) {
ScopedSkipRequestFileSystemDialog dialog_skipper(ui::DIALOG_BUTTON_CANCEL);
ASSERT_TRUE(RunPlatformAppTestWithFlags(
"api_test/file_system/request_file_system_whitelisted_component",
kFlagLoadAsComponent))
<< message_;
}
IN_PROC_BROWSER_TEST_F(FileSystemApiTestForRequestFileSystem,
NotWhitelistedComponent) {
ScopedSkipRequestFileSystemDialog dialog_skipper(ui::DIALOG_BUTTON_OK);
ASSERT_TRUE(RunPlatformAppTestWithFlags(
"api_test/file_system/request_file_system_not_whitelisted_component",
kFlagLoadAsComponent))
<< message_;
}
IN_PROC_BROWSER_TEST_F(FileSystemApiTestForRequestFileSystem, GetVolumeList) {
EnterKioskSession();
ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/get_volume_list"))
<< message_;
}
IN_PROC_BROWSER_TEST_F(FileSystemApiTestForRequestFileSystem,
GetVolumeList_NotKioskSession) {
ASSERT_TRUE(RunPlatformAppTest(
"api_test/file_system/get_volume_list_not_kiosk_session"))
<< message_;
}
IN_PROC_BROWSER_TEST_F(FileSystemApiTestForRequestFileSystem,
OnVolumeListChanged) {
EnterKioskSession();
ScopedAddListenerObserver observer(
profile(), extensions::api::file_system::OnVolumeListChanged::kEventName,
kTestingExtensionId,
base::BindOnce(&FileSystemApiTestForRequestFileSystem::MountFakeVolume,
base::Unretained(this)));
ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/on_volume_list_changed"))
<< message_;
}
IN_PROC_BROWSER_TEST_F(FileSystemApiTestForRequestFileSystem,
WhitelistedExtensionForDownloads) {
ScopedSkipRequestFileSystemDialog dialog_skipper(ui::DIALOG_BUTTON_CANCEL);
ASSERT_TRUE(RunPlatformAppTestWithFlags(
"api_test/file_system/request_downloads_whitelisted_extension",
kFlagLaunchPlatformApp))
<< message_;
}
} // namespace extensions
|