OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "chrome/browser/extensions/api/file_system/file_system_api.h" | 7 #include "chrome/browser/extensions/api/file_system/file_system_api.h" |
8 #include "chrome/browser/extensions/platform_app_browsertest_util.h" | 8 #include "chrome/browser/extensions/platform_app_browsertest_util.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | |
9 | 10 |
10 using extensions::FileSystemChooseFileFunction; | 11 using extensions::FileSystemChooseFileFunction; |
11 | 12 |
12 class FileSystemApiTest : public PlatformAppBrowserTest { | 13 class FileSystemApiTest : public PlatformAppBrowserTest { |
13 public: | 14 public: |
14 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 15 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
15 PlatformAppBrowserTest::SetUpCommandLine(command_line); | 16 PlatformAppBrowserTest::SetUpCommandLine(command_line); |
16 test_root_folder_ = test_data_dir_.AppendASCII("api_test") | 17 test_root_folder_ = test_data_dir_.AppendASCII("api_test") |
17 .AppendASCII("file_system"); | 18 .AppendASCII("file_system"); |
18 } | 19 } |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 } | 196 } |
196 | 197 |
197 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiIsWritableTest) { | 198 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiIsWritableTest) { |
198 FilePath test_file = TempFilePath("writable.txt", true); | 199 FilePath test_file = TempFilePath("writable.txt", true); |
199 ASSERT_FALSE(test_file.empty()); | 200 ASSERT_FALSE(test_file.empty()); |
200 FileSystemChooseFileFunction::SkipPickerAndAlwaysSelectPathForTest( | 201 FileSystemChooseFileFunction::SkipPickerAndAlwaysSelectPathForTest( |
201 &test_file); | 202 &test_file); |
202 ASSERT_TRUE(RunPlatformAppTest( | 203 ASSERT_TRUE(RunPlatformAppTest( |
203 "api_test/file_system/is_writable_file_entry")) << message_; | 204 "api_test/file_system/is_writable_file_entry")) << message_; |
204 } | 205 } |
206 | |
207 class FileSystemApiUnitTest : public testing::Test { | |
benwells
2012/07/26 08:10:23
This should go in file file_system_unittest.cc, an
thorogood
2012/07/27 03:14:38
Done.
| |
208 }; | |
209 | |
210 TEST_F(FileSystemApiUnitTest, | |
211 FileSystemChooseFileFunctionFileTypeInfoTest) { | |
212 // AcceptsAllTypes is ignored when no other extensions are available. | |
213 scoped_ptr<SelectFileDialog::FileTypeInfo> file_type_info( | |
214 new SelectFileDialog::FileTypeInfo()); | |
215 bool acceptsAllTypes = false; | |
216 FileSystemChooseFileFunction::BuildFileTypeInfo(file_type_info.get(), | |
217 NULL, &acceptsAllTypes); | |
218 EXPECT_TRUE(file_type_info->include_all_files); | |
219 EXPECT_TRUE(file_type_info->extensions.empty()); | |
220 | |
221 // Test grouping of multiple types. | |
222 file_type_info.reset(new SelectFileDialog::FileTypeInfo()); | |
223 std::vector<std::string> accepts; | |
224 accepts.push_back(".jso,application/x-chrome-extension"); | |
225 acceptsAllTypes = false; | |
226 FileSystemChooseFileFunction::BuildFileTypeInfo(file_type_info.get(), | |
227 &accepts, &acceptsAllTypes); | |
228 EXPECT_FALSE(file_type_info->include_all_files); | |
229 EXPECT_EQ(file_type_info->extensions.size(), (size_t) 1); | |
230 } | |
OLD | NEW |