OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/ui/views/select_file_dialog_extension.h" | 5 #include "chrome/browser/ui/views/select_file_dialog_extension.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
211 #if !defined(OS_CHROMEOS) | 211 #if !defined(OS_CHROMEOS) |
212 #define MAYBE_SelectFileAndCancel DISABLED_SelectFileAndCancel | 212 #define MAYBE_SelectFileAndCancel DISABLED_SelectFileAndCancel |
213 #else | 213 #else |
214 #define MAYBE_SelectFileAndCancel SelectFileAndCancel | 214 #define MAYBE_SelectFileAndCancel SelectFileAndCancel |
215 #endif | 215 #endif |
216 IN_PROC_BROWSER_TEST_F(SelectFileDialogExtensionBrowserTest, | 216 IN_PROC_BROWSER_TEST_F(SelectFileDialogExtensionBrowserTest, |
217 MAYBE_SelectFileAndCancel) { | 217 MAYBE_SelectFileAndCancel) { |
218 // Add tmp mount point even though this test won't use it directly. | 218 // Add tmp mount point even though this test won't use it directly. |
219 // We need this to make sure that at least one top-level directory exists | 219 // We need this to make sure that at least one top-level directory exists |
220 // in the file browser. | 220 // in the file browser. |
221 FilePath tmp_dir("/tmp"); | 221 FilePath tmp_dir("/tmp/Downloads"); |
222 file_util::CreateDirectory(tmp_dir); | |
zel
2011/12/06 16:14:19
You should use ScopedTempDir class for this purpos
dgozman
2011/12/06 17:11:55
Done.
| |
222 AddMountPoint(tmp_dir); | 223 AddMountPoint(tmp_dir); |
223 | 224 |
224 gfx::NativeWindow owning_window = browser()->window()->GetNativeHandle(); | 225 gfx::NativeWindow owning_window = browser()->window()->GetNativeHandle(); |
225 | 226 |
226 // FilePath() for default path. | 227 // FilePath() for default path. |
227 OpenDialog(SelectFileDialog::SELECT_OPEN_FILE, FilePath(), owning_window, ""); | 228 OpenDialog(SelectFileDialog::SELECT_OPEN_FILE, FilePath(), owning_window, ""); |
228 | 229 |
229 // Press cancel button. | 230 // Press cancel button. |
230 CloseDialog(DIALOG_BTN_CANCEL, owning_window); | 231 CloseDialog(DIALOG_BTN_CANCEL, owning_window); |
231 | 232 |
232 // Listener should have been informed of the cancellation. | 233 // Listener should have been informed of the cancellation. |
233 ASSERT_FALSE(listener_->file_selected()); | 234 ASSERT_FALSE(listener_->file_selected()); |
234 ASSERT_TRUE(listener_->canceled()); | 235 ASSERT_TRUE(listener_->canceled()); |
235 ASSERT_EQ(this, listener_->params()); | 236 ASSERT_EQ(this, listener_->params()); |
236 } | 237 } |
237 | 238 |
238 // TODO(jamescook): Make dialog work on non-ChromeOS platforms. crbug.com/97424 | 239 // TODO(jamescook): Make dialog work on non-ChromeOS platforms. crbug.com/97424 |
239 #if !defined(OS_CHROMEOS) | 240 #if !defined(OS_CHROMEOS) |
240 #define MAYBE_SelectFileAndOpen DISABLED_SelectFileAndOpen | 241 #define MAYBE_SelectFileAndOpen DISABLED_SelectFileAndOpen |
241 #else | 242 #else |
242 #define MAYBE_SelectFileAndOpen SelectFileAndOpen | 243 #define MAYBE_SelectFileAndOpen SelectFileAndOpen |
243 #endif | 244 #endif |
244 IN_PROC_BROWSER_TEST_F(SelectFileDialogExtensionBrowserTest, | 245 IN_PROC_BROWSER_TEST_F(SelectFileDialogExtensionBrowserTest, |
245 MAYBE_SelectFileAndOpen) { | 246 MAYBE_SelectFileAndOpen) { |
246 // Allow the tmp directory to be mounted. We explicitly use /tmp because | 247 // Allow the tmp directory to be mounted. We explicitly use /tmp because |
247 // it it whitelisted for file system access on Chrome OS. | 248 // it is whitelisted for file system access on Chrome OS. |
248 FilePath tmp_dir("/tmp"); | 249 // File manager looks for Downloads mount point, so use this name. |
250 FilePath tmp_dir("/tmp/Downloads"); | |
251 file_util::CreateDirectory(tmp_dir); | |
249 AddMountPoint(tmp_dir); | 252 AddMountPoint(tmp_dir); |
250 | 253 |
251 // Create a directory with a single file in it. ScopedTempDir will delete | 254 // Create a directory with a single file in it. ScopedTempDir will delete |
252 // itself and our temp file when it goes out of scope. | 255 // itself and our temp file when it goes out of scope. |
253 ScopedTempDir scoped_temp_dir; | 256 ScopedTempDir scoped_temp_dir; |
254 ASSERT_TRUE(scoped_temp_dir.CreateUniqueTempDirUnderPath(tmp_dir)); | 257 ASSERT_TRUE(scoped_temp_dir.CreateUniqueTempDirUnderPath(tmp_dir)); |
255 FilePath temp_dir = scoped_temp_dir.path(); | 258 FilePath temp_dir = scoped_temp_dir.path(); |
256 FilePath test_file = temp_dir.AppendASCII("file_manager_test.html"); | 259 FilePath test_file = temp_dir.AppendASCII("file_manager_test.html"); |
257 | 260 |
258 // Create an empty file to give us something to select. | 261 // Create an empty file to give us something to select. |
(...skipping 23 matching lines...) Expand all Loading... | |
282 | 285 |
283 // TODO(jamescook): Make dialog work on non-ChromeOS platforms. crbug.com/97424 | 286 // TODO(jamescook): Make dialog work on non-ChromeOS platforms. crbug.com/97424 |
284 #if !defined(OS_CHROMEOS) | 287 #if !defined(OS_CHROMEOS) |
285 #define MAYBE_SelectFileAndSave DISABLED_SelectFileAndSave | 288 #define MAYBE_SelectFileAndSave DISABLED_SelectFileAndSave |
286 #else | 289 #else |
287 #define MAYBE_SelectFileAndSave SelectFileAndSave | 290 #define MAYBE_SelectFileAndSave SelectFileAndSave |
288 #endif | 291 #endif |
289 IN_PROC_BROWSER_TEST_F(SelectFileDialogExtensionBrowserTest, | 292 IN_PROC_BROWSER_TEST_F(SelectFileDialogExtensionBrowserTest, |
290 MAYBE_SelectFileAndSave) { | 293 MAYBE_SelectFileAndSave) { |
291 // Allow the tmp directory to be mounted. We explicitly use /tmp because | 294 // Allow the tmp directory to be mounted. We explicitly use /tmp because |
292 // it it whitelisted for file system access on Chrome OS. | 295 // it is whitelisted for file system access on Chrome OS. |
293 FilePath tmp_dir("/tmp"); | 296 // File manager looks for Downloads mount point, so use this name. |
297 FilePath tmp_dir("/tmp/Downloads"); | |
298 file_util::CreateDirectory(tmp_dir); | |
294 AddMountPoint(tmp_dir); | 299 AddMountPoint(tmp_dir); |
295 | 300 |
296 // Create a directory with a single file in it. ScopedTempDir will delete | 301 // Create a directory with a single file in it. ScopedTempDir will delete |
297 // itself and our temp file when it goes out of scope. | 302 // itself and our temp file when it goes out of scope. |
298 ScopedTempDir scoped_temp_dir; | 303 ScopedTempDir scoped_temp_dir; |
299 ASSERT_TRUE(scoped_temp_dir.CreateUniqueTempDirUnderPath(tmp_dir)); | 304 ASSERT_TRUE(scoped_temp_dir.CreateUniqueTempDirUnderPath(tmp_dir)); |
300 FilePath temp_dir = scoped_temp_dir.path(); | 305 FilePath temp_dir = scoped_temp_dir.path(); |
301 FilePath test_file = temp_dir.AppendASCII("file_manager_test.html"); | 306 FilePath test_file = temp_dir.AppendASCII("file_manager_test.html"); |
302 | 307 |
303 gfx::NativeWindow owning_window = browser()->window()->GetNativeHandle(); | 308 gfx::NativeWindow owning_window = browser()->window()->GetNativeHandle(); |
(...skipping 20 matching lines...) Expand all Loading... | |
324 #if !defined(OS_CHROMEOS) | 329 #if !defined(OS_CHROMEOS) |
325 #define MAYBE_OpenSingletonTabAndCancel DISABLED_OpenSingletonTabAndCancel | 330 #define MAYBE_OpenSingletonTabAndCancel DISABLED_OpenSingletonTabAndCancel |
326 #else | 331 #else |
327 #define MAYBE_OpenSingletonTabAndCancel OpenSingletonTabAndCancel | 332 #define MAYBE_OpenSingletonTabAndCancel OpenSingletonTabAndCancel |
328 #endif | 333 #endif |
329 IN_PROC_BROWSER_TEST_F(SelectFileDialogExtensionBrowserTest, | 334 IN_PROC_BROWSER_TEST_F(SelectFileDialogExtensionBrowserTest, |
330 MAYBE_OpenSingletonTabAndCancel) { | 335 MAYBE_OpenSingletonTabAndCancel) { |
331 // Add tmp mount point even though this test won't use it directly. | 336 // Add tmp mount point even though this test won't use it directly. |
332 // We need this to make sure that at least one top-level directory exists | 337 // We need this to make sure that at least one top-level directory exists |
333 // in the file browser. | 338 // in the file browser. |
334 FilePath tmp_dir("/tmp"); | 339 FilePath tmp_dir("/tmp/Downloads"); |
340 file_util::CreateDirectory(tmp_dir); | |
335 AddMountPoint(tmp_dir); | 341 AddMountPoint(tmp_dir); |
336 | 342 |
337 gfx::NativeWindow owning_window = browser()->window()->GetNativeHandle(); | 343 gfx::NativeWindow owning_window = browser()->window()->GetNativeHandle(); |
338 | 344 |
339 OpenDialog(SelectFileDialog::SELECT_OPEN_FILE, FilePath(), owning_window, ""); | 345 OpenDialog(SelectFileDialog::SELECT_OPEN_FILE, FilePath(), owning_window, ""); |
340 | 346 |
341 // Open a singleton tab in background. | 347 // Open a singleton tab in background. |
342 browser::NavigateParams p(browser(), GURL("www.google.com"), | 348 browser::NavigateParams p(browser(), GURL("www.google.com"), |
343 content::PAGE_TRANSITION_LINK); | 349 content::PAGE_TRANSITION_LINK); |
344 p.window_action = browser::NavigateParams::SHOW_WINDOW; | 350 p.window_action = browser::NavigateParams::SHOW_WINDOW; |
(...skipping 13 matching lines...) Expand all Loading... | |
358 #if !defined(OS_CHROMEOS) | 364 #if !defined(OS_CHROMEOS) |
359 #define MAYBE_OpenTwoDialogs DISABLED_OpenTwoDialogs | 365 #define MAYBE_OpenTwoDialogs DISABLED_OpenTwoDialogs |
360 #else | 366 #else |
361 #define MAYBE_OpenTwoDialogs OpenTwoDialogs | 367 #define MAYBE_OpenTwoDialogs OpenTwoDialogs |
362 #endif | 368 #endif |
363 IN_PROC_BROWSER_TEST_F(SelectFileDialogExtensionBrowserTest, | 369 IN_PROC_BROWSER_TEST_F(SelectFileDialogExtensionBrowserTest, |
364 MAYBE_OpenTwoDialogs) { | 370 MAYBE_OpenTwoDialogs) { |
365 // Add tmp mount point even though this test won't use it directly. | 371 // Add tmp mount point even though this test won't use it directly. |
366 // We need this to make sure that at least one top-level directory exists | 372 // We need this to make sure that at least one top-level directory exists |
367 // in the file browser. | 373 // in the file browser. |
368 FilePath tmp_dir("/tmp"); | 374 FilePath tmp_dir("/tmp/Downloads"); |
375 file_util::CreateDirectory(tmp_dir); | |
369 AddMountPoint(tmp_dir); | 376 AddMountPoint(tmp_dir); |
370 | 377 |
371 gfx::NativeWindow owning_window = browser()->window()->GetNativeHandle(); | 378 gfx::NativeWindow owning_window = browser()->window()->GetNativeHandle(); |
372 | 379 |
373 OpenDialog(SelectFileDialog::SELECT_OPEN_FILE, FilePath(), owning_window, ""); | 380 OpenDialog(SelectFileDialog::SELECT_OPEN_FILE, FilePath(), owning_window, ""); |
374 | 381 |
375 TryOpeningSecondDialog(owning_window); | 382 TryOpeningSecondDialog(owning_window); |
376 | 383 |
377 // Second dialog should not be running. | 384 // Second dialog should not be running. |
378 ASSERT_FALSE(second_dialog_->IsRunning(owning_window)); | 385 ASSERT_FALSE(second_dialog_->IsRunning(owning_window)); |
379 | 386 |
380 // Click cancel button. | 387 // Click cancel button. |
381 CloseDialog(DIALOG_BTN_CANCEL, owning_window); | 388 CloseDialog(DIALOG_BTN_CANCEL, owning_window); |
382 | 389 |
383 // Listener should have been informed of the cancellation. | 390 // Listener should have been informed of the cancellation. |
384 ASSERT_FALSE(listener_->file_selected()); | 391 ASSERT_FALSE(listener_->file_selected()); |
385 ASSERT_TRUE(listener_->canceled()); | 392 ASSERT_TRUE(listener_->canceled()); |
386 ASSERT_EQ(this, listener_->params()); | 393 ASSERT_EQ(this, listener_->params()); |
387 } | 394 } |
OLD | NEW |