| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Browser test for basic Chrome OS file manager functionality: | 5 // Browser test for basic Chrome OS file manager functionality: |
| 6 // - The file list is updated when a file is added externally to the Downloads | 6 // - The file list is updated when a file is added externally to the Downloads |
| 7 // folder. | 7 // folder. |
| 8 // - Selecting a file and copy-pasting it with the keyboard copies the file. | 8 // - Selecting a file and copy-pasting it with the keyboard copies the file. |
| 9 // - Selecting a file and pressing delete deletes it. | 9 // - Selecting a file and pressing delete deletes it. |
| 10 | 10 |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 DriveTestVolume() : fake_drive_service_(NULL), | 268 DriveTestVolume() : fake_drive_service_(NULL), |
| 269 integration_service_(NULL) { | 269 integration_service_(NULL) { |
| 270 } | 270 } |
| 271 | 271 |
| 272 // Sends request to add this volume to the file system as Google drive. | 272 // Sends request to add this volume to the file system as Google drive. |
| 273 // This method must be calld at SetUp method of FileManagerBrowserTestBase. | 273 // This method must be calld at SetUp method of FileManagerBrowserTestBase. |
| 274 // Returns true on success. | 274 // Returns true on success. |
| 275 bool SetUp() { | 275 bool SetUp() { |
| 276 if (!test_cache_root_.CreateUniqueTempDir()) | 276 if (!test_cache_root_.CreateUniqueTempDir()) |
| 277 return false; | 277 return false; |
| 278 create_drive_integration_service_ = |
| 279 base::Bind(&DriveTestVolume::CreateDriveIntegrationService, |
| 280 base::Unretained(this)); |
| 278 drive::DriveIntegrationServiceFactory::SetFactoryForTest( | 281 drive::DriveIntegrationServiceFactory::SetFactoryForTest( |
| 279 base::Bind(&DriveTestVolume::CreateDriveIntegrationService, | 282 &create_drive_integration_service_); |
| 280 base::Unretained(this))); | |
| 281 return true; | 283 return true; |
| 282 } | 284 } |
| 283 | 285 |
| 286 void TearDown() { |
| 287 drive::DriveIntegrationServiceFactory::SetFactoryForTest(NULL); |
| 288 } |
| 289 |
| 284 void CreateEntry(const TestEntryInfo& entry) { | 290 void CreateEntry(const TestEntryInfo& entry) { |
| 285 const base::FilePath path = | 291 const base::FilePath path = |
| 286 base::FilePath::FromUTF8Unsafe(entry.target_path); | 292 base::FilePath::FromUTF8Unsafe(entry.target_path); |
| 287 const std::string target_name = path.BaseName().AsUTF8Unsafe(); | 293 const std::string target_name = path.BaseName().AsUTF8Unsafe(); |
| 288 | 294 |
| 289 // Obtain the parent entry. | 295 // Obtain the parent entry. |
| 290 drive::FileError error = drive::FILE_ERROR_OK; | 296 drive::FileError error = drive::FILE_ERROR_OK; |
| 291 scoped_ptr<drive::ResourceEntry> parent_entry(new drive::ResourceEntry); | 297 scoped_ptr<drive::ResourceEntry> parent_entry(new drive::ResourceEntry); |
| 292 integration_service_->file_system()->GetResourceEntry( | 298 integration_service_->file_system()->GetResourceEntry( |
| 293 drive::util::GetDriveMyDriveRootPath().Append(path).DirName(), | 299 drive::util::GetDriveMyDriveRootPath().Append(path).DirName(), |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 fake_drive_service_->LoadAppListForDriveApi("drive/applist.json"); | 413 fake_drive_service_->LoadAppListForDriveApi("drive/applist.json"); |
| 408 integration_service_ = new drive::DriveIntegrationService( | 414 integration_service_ = new drive::DriveIntegrationService( |
| 409 profile, NULL, fake_drive_service_, test_cache_root_.path(), NULL); | 415 profile, NULL, fake_drive_service_, test_cache_root_.path(), NULL); |
| 410 return integration_service_; | 416 return integration_service_; |
| 411 } | 417 } |
| 412 | 418 |
| 413 private: | 419 private: |
| 414 base::ScopedTempDir test_cache_root_; | 420 base::ScopedTempDir test_cache_root_; |
| 415 drive::FakeDriveService* fake_drive_service_; | 421 drive::FakeDriveService* fake_drive_service_; |
| 416 drive::DriveIntegrationService* integration_service_; | 422 drive::DriveIntegrationService* integration_service_; |
| 423 drive::DriveIntegrationServiceFactory::FactoryCallback |
| 424 create_drive_integration_service_; |
| 417 }; | 425 }; |
| 418 | 426 |
| 419 // Listener to obtain the test relative messages synchronously. | 427 // Listener to obtain the test relative messages synchronously. |
| 420 class FileManagerTestListener : public content::NotificationObserver { | 428 class FileManagerTestListener : public content::NotificationObserver { |
| 421 public: | 429 public: |
| 422 struct Message { | 430 struct Message { |
| 423 int type; | 431 int type; |
| 424 std::string message; | 432 std::string message; |
| 425 scoped_refptr<extensions::TestSendMessageFunction> function; | 433 scoped_refptr<extensions::TestSendMessageFunction> function; |
| 426 }; | 434 }; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 | 489 |
| 482 virtual void SetUp() OVERRIDE { | 490 virtual void SetUp() OVERRIDE { |
| 483 // TODO(danakj): The GPU Video Decoder needs real GL bindings. | 491 // TODO(danakj): The GPU Video Decoder needs real GL bindings. |
| 484 // crbug.com/269087 | 492 // crbug.com/269087 |
| 485 UseRealGLBindings(); | 493 UseRealGLBindings(); |
| 486 | 494 |
| 487 ExtensionApiTest::SetUp(); | 495 ExtensionApiTest::SetUp(); |
| 488 } | 496 } |
| 489 | 497 |
| 490 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE; | 498 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE; |
| 499 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE; |
| 491 | 500 |
| 492 virtual void SetUpOnMainThread() OVERRIDE; | 501 virtual void SetUpOnMainThread() OVERRIDE; |
| 493 | 502 |
| 494 // Adds an incognito and guest-mode flags for tests in the guest mode. | 503 // Adds an incognito and guest-mode flags for tests in the guest mode. |
| 495 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; | 504 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; |
| 496 | 505 |
| 497 // Loads our testing extension and sends it a string identifying the current | 506 // Loads our testing extension and sends it a string identifying the current |
| 498 // test. | 507 // test. |
| 499 void StartTest(); | 508 void StartTest(); |
| 500 | 509 |
| 501 const scoped_ptr<LocalTestVolume> local_volume_; | 510 const scoped_ptr<LocalTestVolume> local_volume_; |
| 502 const scoped_ptr<DriveTestVolume> drive_volume_; | 511 const scoped_ptr<DriveTestVolume> drive_volume_; |
| 503 }; | 512 }; |
| 504 | 513 |
| 505 void FileManagerBrowserTest::SetUpInProcessBrowserTestFixture() { | 514 void FileManagerBrowserTest::SetUpInProcessBrowserTestFixture() { |
| 506 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); | 515 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); |
| 507 extensions::ComponentLoader::EnableBackgroundExtensionsForTesting(); | 516 extensions::ComponentLoader::EnableBackgroundExtensionsForTesting(); |
| 508 if (drive_volume_) | 517 if (drive_volume_) |
| 509 ASSERT_TRUE(drive_volume_->SetUp()); | 518 ASSERT_TRUE(drive_volume_->SetUp()); |
| 510 } | 519 } |
| 511 | 520 |
| 521 void FileManagerBrowserTest::TearDownInProcessBrowserTestFixture() { |
| 522 if (drive_volume_) |
| 523 drive_volume_->TearDown(); |
| 524 ExtensionApiTest::TearDownInProcessBrowserTestFixture(); |
| 525 } |
| 526 |
| 512 void FileManagerBrowserTest::SetUpOnMainThread() { | 527 void FileManagerBrowserTest::SetUpOnMainThread() { |
| 513 ExtensionApiTest::SetUpOnMainThread(); | 528 ExtensionApiTest::SetUpOnMainThread(); |
| 514 ASSERT_TRUE(local_volume_->Mount(browser()->profile())); | 529 ASSERT_TRUE(local_volume_->Mount(browser()->profile())); |
| 515 | 530 |
| 516 if (drive_volume_) { | 531 if (drive_volume_) { |
| 517 // Install the web server to serve the mocked share dialog. | 532 // Install the web server to serve the mocked share dialog. |
| 518 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 533 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 519 const GURL share_url_base(embedded_test_server()->GetURL( | 534 const GURL share_url_base(embedded_test_server()->GetURL( |
| 520 "/chromeos/file_manager/share_dialog_mock/index.html")); | 535 "/chromeos/file_manager/share_dialog_mock/index.html")); |
| 521 drive_volume_->ConfigureShareUrlBase(share_url_base); | 536 drive_volume_->ConfigureShareUrlBase(share_url_base); |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "searchBoxFocus"))); | 756 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "searchBoxFocus"))); |
| 742 | 757 |
| 743 INSTANTIATE_TEST_CASE_P( | 758 INSTANTIATE_TEST_CASE_P( |
| 744 Thumbnails, | 759 Thumbnails, |
| 745 FileManagerBrowserTest, | 760 FileManagerBrowserTest, |
| 746 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "thumbnailsDownloads"), | 761 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "thumbnailsDownloads"), |
| 747 TestParameter(IN_GUEST_MODE, "thumbnailsDownloads"))); | 762 TestParameter(IN_GUEST_MODE, "thumbnailsDownloads"))); |
| 748 | 763 |
| 749 } // namespace | 764 } // namespace |
| 750 } // namespace file_manager | 765 } // namespace file_manager |
| OLD | NEW |