OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/file_util.h" |
| 6 #include "chrome/browser/extensions/api/file_system/file_system_api.h" |
| 7 #include "chrome/browser/extensions/platform_app_browsertest_util.h" |
| 8 |
| 9 class FileSystemApiTest : public PlatformAppBrowserTest { |
| 10 public: |
| 11 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 12 PlatformAppBrowserTest::SetUpCommandLine(command_line); |
| 13 test_file_folder_ = test_data_dir_.AppendASCII("api_test") |
| 14 .AppendASCII("file_system"); |
| 15 } |
| 16 |
| 17 virtual void TearDown() OVERRIDE { |
| 18 extensions::FileSystemPickerFunction::StopSkippingPicker(); |
| 19 PlatformAppBrowserTest::TearDown(); |
| 20 }; |
| 21 |
| 22 protected: |
| 23 FilePath test_file_folder_; |
| 24 }; |
| 25 |
| 26 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiGetDisplayPath) { |
| 27 FilePath test_file = test_file_folder_.AppendASCII("open_existing.txt"); |
| 28 extensions::FileSystemPickerFunction::SkipPickerAndAlwaysSelectPath( |
| 29 &test_file); |
| 30 ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/get_display_path")) |
| 31 << message_; |
| 32 } |
| 33 |
| 34 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiOpenExistingFileTest) { |
| 35 FilePath test_file = test_file_folder_.AppendASCII("open_existing.txt"); |
| 36 extensions::FileSystemPickerFunction::SkipPickerAndAlwaysSelectPath( |
| 37 &test_file); |
| 38 ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/open_existing")) |
| 39 << message_; |
| 40 } |
| 41 |
| 42 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiOpenCancelTest) { |
| 43 extensions::FileSystemPickerFunction::SkipPickerAndAlwaysCancel(); |
| 44 ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/open_cancel")) |
| 45 << message_; |
| 46 } |
| 47 |
| 48 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiOpenBackgroundTest) { |
| 49 ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/open_background")) |
| 50 << message_; |
| 51 } |
| 52 |
| 53 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiSaveNewFileTest) { |
| 54 FilePath test_file = test_file_folder_.AppendASCII("save_new.txt"); |
| 55 // Make sure test file path does not exist. |
| 56 ASSERT_TRUE(file_util::Delete(test_file, false)); |
| 57 extensions::FileSystemPickerFunction::SkipPickerAndAlwaysSelectPath( |
| 58 &test_file); |
| 59 ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/save_new")) |
| 60 << message_; |
| 61 } |
| 62 |
| 63 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiSaveExistingFileTest) { |
| 64 FilePath test_file = test_file_folder_.AppendASCII("save_existing.txt"); |
| 65 // Replace test save file to make sure it's pristine. |
| 66 ASSERT_TRUE(file_util::CopyFile( |
| 67 test_file_folder_.AppendASCII("open_existing.txt"), test_file)); |
| 68 extensions::FileSystemPickerFunction::SkipPickerAndAlwaysSelectPath( |
| 69 &test_file); |
| 70 ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/save_existing")) |
| 71 << message_; |
| 72 } |
| 73 |
| 74 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiSaveCancelTest) { |
| 75 extensions::FileSystemPickerFunction::SkipPickerAndAlwaysCancel(); |
| 76 ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/save_cancel")) |
| 77 << message_; |
| 78 } |
| 79 |
| 80 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiSaveBackgroundTest) { |
| 81 ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/save_background")) |
| 82 << message_; |
| 83 } |
OLD | NEW |