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 ScopedTempDir downloads_dir; | |
223 ASSERT_TRUE(downloads_dir.Set(tmp_dir)); | |
zel
2011/12/06 17:29:29
I suggest something like this instead:
ScopedTemp
zel
2011/12/06 17:42:02
Shorter version:
ScopedTempDir downloads_dir;
ASS
dgozman
2011/12/07 11:20:42
Done.
| |
222 AddMountPoint(tmp_dir); | 224 AddMountPoint(tmp_dir); |
223 | 225 |
224 gfx::NativeWindow owning_window = browser()->window()->GetNativeHandle(); | 226 gfx::NativeWindow owning_window = browser()->window()->GetNativeHandle(); |
225 | 227 |
226 // FilePath() for default path. | 228 // FilePath() for default path. |
227 OpenDialog(SelectFileDialog::SELECT_OPEN_FILE, FilePath(), owning_window, ""); | 229 OpenDialog(SelectFileDialog::SELECT_OPEN_FILE, FilePath(), owning_window, ""); |
228 | 230 |
229 // Press cancel button. | 231 // Press cancel button. |
230 CloseDialog(DIALOG_BTN_CANCEL, owning_window); | 232 CloseDialog(DIALOG_BTN_CANCEL, owning_window); |
231 | 233 |
232 // Listener should have been informed of the cancellation. | 234 // Listener should have been informed of the cancellation. |
233 ASSERT_FALSE(listener_->file_selected()); | 235 ASSERT_FALSE(listener_->file_selected()); |
234 ASSERT_TRUE(listener_->canceled()); | 236 ASSERT_TRUE(listener_->canceled()); |
235 ASSERT_EQ(this, listener_->params()); | 237 ASSERT_EQ(this, listener_->params()); |
236 } | 238 } |
237 | 239 |
238 // TODO(jamescook): Make dialog work on non-ChromeOS platforms. crbug.com/97424 | 240 // TODO(jamescook): Make dialog work on non-ChromeOS platforms. crbug.com/97424 |
239 #if !defined(OS_CHROMEOS) | 241 #if !defined(OS_CHROMEOS) |
240 #define MAYBE_SelectFileAndOpen DISABLED_SelectFileAndOpen | 242 #define MAYBE_SelectFileAndOpen DISABLED_SelectFileAndOpen |
241 #else | 243 #else |
242 #define MAYBE_SelectFileAndOpen SelectFileAndOpen | 244 #define MAYBE_SelectFileAndOpen SelectFileAndOpen |
243 #endif | 245 #endif |
244 IN_PROC_BROWSER_TEST_F(SelectFileDialogExtensionBrowserTest, | 246 IN_PROC_BROWSER_TEST_F(SelectFileDialogExtensionBrowserTest, |
245 MAYBE_SelectFileAndOpen) { | 247 MAYBE_SelectFileAndOpen) { |
246 // Allow the tmp directory to be mounted. We explicitly use /tmp because | 248 // Allow the tmp directory to be mounted. We explicitly use /tmp because |
247 // it it whitelisted for file system access on Chrome OS. | 249 // it is whitelisted for file system access on Chrome OS. |
248 FilePath tmp_dir("/tmp"); | 250 // File manager looks for Downloads mount point, so use this name. |
251 FilePath tmp_dir("/tmp/Downloads"); | |
sky
2011/12/06 17:23:59
You want PathService::Get(base::DIR_TEMP, &tmp_pat
dgozman
2011/12/07 11:20:42
Done.
| |
252 ScopedTempDir downloads_dir; | |
253 ASSERT_TRUE(downloads_dir.Set(tmp_dir)); | |
249 AddMountPoint(tmp_dir); | 254 AddMountPoint(tmp_dir); |
250 | 255 |
251 // Create a directory with a single file in it. ScopedTempDir will delete | 256 // Create a directory with a single file in it. ScopedTempDir will delete |
252 // itself and our temp file when it goes out of scope. | 257 // itself and our temp file when it goes out of scope. |
253 ScopedTempDir scoped_temp_dir; | 258 ScopedTempDir scoped_temp_dir; |
254 ASSERT_TRUE(scoped_temp_dir.CreateUniqueTempDirUnderPath(tmp_dir)); | 259 ASSERT_TRUE(scoped_temp_dir.CreateUniqueTempDirUnderPath(tmp_dir)); |
255 FilePath temp_dir = scoped_temp_dir.path(); | 260 FilePath temp_dir = scoped_temp_dir.path(); |
256 FilePath test_file = temp_dir.AppendASCII("file_manager_test.html"); | 261 FilePath test_file = temp_dir.AppendASCII("file_manager_test.html"); |
257 | 262 |
258 // Create an empty file to give us something to select. | 263 // Create an empty file to give us something to select. |
(...skipping 23 matching lines...) Expand all Loading... | |
282 | 287 |
283 // TODO(jamescook): Make dialog work on non-ChromeOS platforms. crbug.com/97424 | 288 // TODO(jamescook): Make dialog work on non-ChromeOS platforms. crbug.com/97424 |
284 #if !defined(OS_CHROMEOS) | 289 #if !defined(OS_CHROMEOS) |
285 #define MAYBE_SelectFileAndSave DISABLED_SelectFileAndSave | 290 #define MAYBE_SelectFileAndSave DISABLED_SelectFileAndSave |
286 #else | 291 #else |
287 #define MAYBE_SelectFileAndSave SelectFileAndSave | 292 #define MAYBE_SelectFileAndSave SelectFileAndSave |
288 #endif | 293 #endif |
289 IN_PROC_BROWSER_TEST_F(SelectFileDialogExtensionBrowserTest, | 294 IN_PROC_BROWSER_TEST_F(SelectFileDialogExtensionBrowserTest, |
290 MAYBE_SelectFileAndSave) { | 295 MAYBE_SelectFileAndSave) { |
291 // Allow the tmp directory to be mounted. We explicitly use /tmp because | 296 // Allow the tmp directory to be mounted. We explicitly use /tmp because |
292 // it it whitelisted for file system access on Chrome OS. | 297 // it is whitelisted for file system access on Chrome OS. |
293 FilePath tmp_dir("/tmp"); | 298 // File manager looks for Downloads mount point, so use this name. |
299 FilePath tmp_dir("/tmp/Downloads"); | |
300 ScopedTempDir downloads_dir; | |
301 ASSERT_TRUE(downloads_dir.Set(tmp_dir)); | |
294 AddMountPoint(tmp_dir); | 302 AddMountPoint(tmp_dir); |
295 | 303 |
296 // Create a directory with a single file in it. ScopedTempDir will delete | 304 // Create a directory with a single file in it. ScopedTempDir will delete |
297 // itself and our temp file when it goes out of scope. | 305 // itself and our temp file when it goes out of scope. |
298 ScopedTempDir scoped_temp_dir; | 306 ScopedTempDir scoped_temp_dir; |
299 ASSERT_TRUE(scoped_temp_dir.CreateUniqueTempDirUnderPath(tmp_dir)); | 307 ASSERT_TRUE(scoped_temp_dir.CreateUniqueTempDirUnderPath(tmp_dir)); |
300 FilePath temp_dir = scoped_temp_dir.path(); | 308 FilePath temp_dir = scoped_temp_dir.path(); |
301 FilePath test_file = temp_dir.AppendASCII("file_manager_test.html"); | 309 FilePath test_file = temp_dir.AppendASCII("file_manager_test.html"); |
302 | 310 |
303 gfx::NativeWindow owning_window = browser()->window()->GetNativeHandle(); | 311 gfx::NativeWindow owning_window = browser()->window()->GetNativeHandle(); |
(...skipping 20 matching lines...) Expand all Loading... | |
324 #if !defined(OS_CHROMEOS) | 332 #if !defined(OS_CHROMEOS) |
325 #define MAYBE_OpenSingletonTabAndCancel DISABLED_OpenSingletonTabAndCancel | 333 #define MAYBE_OpenSingletonTabAndCancel DISABLED_OpenSingletonTabAndCancel |
326 #else | 334 #else |
327 #define MAYBE_OpenSingletonTabAndCancel OpenSingletonTabAndCancel | 335 #define MAYBE_OpenSingletonTabAndCancel OpenSingletonTabAndCancel |
328 #endif | 336 #endif |
329 IN_PROC_BROWSER_TEST_F(SelectFileDialogExtensionBrowserTest, | 337 IN_PROC_BROWSER_TEST_F(SelectFileDialogExtensionBrowserTest, |
330 MAYBE_OpenSingletonTabAndCancel) { | 338 MAYBE_OpenSingletonTabAndCancel) { |
331 // Add tmp mount point even though this test won't use it directly. | 339 // 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 | 340 // We need this to make sure that at least one top-level directory exists |
333 // in the file browser. | 341 // in the file browser. |
334 FilePath tmp_dir("/tmp"); | 342 FilePath tmp_dir("/tmp/Downloads"); |
343 ScopedTempDir downloads_dir; | |
344 ASSERT_TRUE(downloads_dir.Set(tmp_dir)); | |
335 AddMountPoint(tmp_dir); | 345 AddMountPoint(tmp_dir); |
336 | 346 |
337 gfx::NativeWindow owning_window = browser()->window()->GetNativeHandle(); | 347 gfx::NativeWindow owning_window = browser()->window()->GetNativeHandle(); |
338 | 348 |
339 OpenDialog(SelectFileDialog::SELECT_OPEN_FILE, FilePath(), owning_window, ""); | 349 OpenDialog(SelectFileDialog::SELECT_OPEN_FILE, FilePath(), owning_window, ""); |
340 | 350 |
341 // Open a singleton tab in background. | 351 // Open a singleton tab in background. |
342 browser::NavigateParams p(browser(), GURL("www.google.com"), | 352 browser::NavigateParams p(browser(), GURL("www.google.com"), |
343 content::PAGE_TRANSITION_LINK); | 353 content::PAGE_TRANSITION_LINK); |
344 p.window_action = browser::NavigateParams::SHOW_WINDOW; | 354 p.window_action = browser::NavigateParams::SHOW_WINDOW; |
(...skipping 13 matching lines...) Expand all Loading... | |
358 #if !defined(OS_CHROMEOS) | 368 #if !defined(OS_CHROMEOS) |
359 #define MAYBE_OpenTwoDialogs DISABLED_OpenTwoDialogs | 369 #define MAYBE_OpenTwoDialogs DISABLED_OpenTwoDialogs |
360 #else | 370 #else |
361 #define MAYBE_OpenTwoDialogs OpenTwoDialogs | 371 #define MAYBE_OpenTwoDialogs OpenTwoDialogs |
362 #endif | 372 #endif |
363 IN_PROC_BROWSER_TEST_F(SelectFileDialogExtensionBrowserTest, | 373 IN_PROC_BROWSER_TEST_F(SelectFileDialogExtensionBrowserTest, |
364 MAYBE_OpenTwoDialogs) { | 374 MAYBE_OpenTwoDialogs) { |
365 // Add tmp mount point even though this test won't use it directly. | 375 // 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 | 376 // We need this to make sure that at least one top-level directory exists |
367 // in the file browser. | 377 // in the file browser. |
368 FilePath tmp_dir("/tmp"); | 378 FilePath tmp_dir("/tmp/Downloads"); |
379 ScopedTempDir downloads_dir; | |
380 ASSERT_TRUE(downloads_dir.Set(tmp_dir)); | |
369 AddMountPoint(tmp_dir); | 381 AddMountPoint(tmp_dir); |
370 | 382 |
371 gfx::NativeWindow owning_window = browser()->window()->GetNativeHandle(); | 383 gfx::NativeWindow owning_window = browser()->window()->GetNativeHandle(); |
372 | 384 |
373 OpenDialog(SelectFileDialog::SELECT_OPEN_FILE, FilePath(), owning_window, ""); | 385 OpenDialog(SelectFileDialog::SELECT_OPEN_FILE, FilePath(), owning_window, ""); |
374 | 386 |
375 TryOpeningSecondDialog(owning_window); | 387 TryOpeningSecondDialog(owning_window); |
376 | 388 |
377 // Second dialog should not be running. | 389 // Second dialog should not be running. |
378 ASSERT_FALSE(second_dialog_->IsRunning(owning_window)); | 390 ASSERT_FALSE(second_dialog_->IsRunning(owning_window)); |
379 | 391 |
380 // Click cancel button. | 392 // Click cancel button. |
381 CloseDialog(DIALOG_BTN_CANCEL, owning_window); | 393 CloseDialog(DIALOG_BTN_CANCEL, owning_window); |
382 | 394 |
383 // Listener should have been informed of the cancellation. | 395 // Listener should have been informed of the cancellation. |
384 ASSERT_FALSE(listener_->file_selected()); | 396 ASSERT_FALSE(listener_->file_selected()); |
385 ASSERT_TRUE(listener_->canceled()); | 397 ASSERT_TRUE(listener_->canceled()); |
386 ASSERT_EQ(this, listener_->params()); | 398 ASSERT_EQ(this, listener_->params()); |
387 } | 399 } |
OLD | NEW |