| 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 "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/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 } | 265 } |
| 266 | 266 |
| 267 IN_PROC_BROWSER_TEST_F(SelectFileDialogExtensionBrowserTest, | 267 IN_PROC_BROWSER_TEST_F(SelectFileDialogExtensionBrowserTest, |
| 268 SelectFileAndOpen) { | 268 SelectFileAndOpen) { |
| 269 AddMountPoint(downloads_dir_); | 269 AddMountPoint(downloads_dir_); |
| 270 | 270 |
| 271 base::FilePath test_file = | 271 base::FilePath test_file = |
| 272 downloads_dir_.AppendASCII("file_manager_test.html"); | 272 downloads_dir_.AppendASCII("file_manager_test.html"); |
| 273 | 273 |
| 274 // Create an empty file to give us something to select. | 274 // Create an empty file to give us something to select. |
| 275 FILE* fp = file_util::OpenFile(test_file, "w"); | 275 FILE* fp = base::OpenFile(test_file, "w"); |
| 276 ASSERT_TRUE(fp != NULL); | 276 ASSERT_TRUE(fp != NULL); |
| 277 ASSERT_TRUE(file_util::CloseFile(fp)); | 277 ASSERT_TRUE(base::CloseFile(fp)); |
| 278 | 278 |
| 279 gfx::NativeWindow owning_window = browser()->window()->GetNativeWindow(); | 279 gfx::NativeWindow owning_window = browser()->window()->GetNativeWindow(); |
| 280 | 280 |
| 281 // Spawn a dialog to open a file. Provide the path to the file so the dialog | 281 // Spawn a dialog to open a file. Provide the path to the file so the dialog |
| 282 // will automatically select it. Ensure that the OK button is enabled by | 282 // will automatically select it. Ensure that the OK button is enabled by |
| 283 // waiting for chrome.test.sendMessage('selection-change-complete'). | 283 // waiting for chrome.test.sendMessage('selection-change-complete'). |
| 284 // The extension starts a Web Worker to read file metadata, so it may send | 284 // The extension starts a Web Worker to read file metadata, so it may send |
| 285 // 'selection-change-complete' before 'worker-initialized'. This is OK. | 285 // 'selection-change-complete' before 'worker-initialized'. This is OK. |
| 286 ASSERT_NO_FATAL_FAILURE(OpenDialog(ui::SelectFileDialog::SELECT_OPEN_FILE, | 286 ASSERT_NO_FATAL_FAILURE(OpenDialog(ui::SelectFileDialog::SELECT_OPEN_FILE, |
| 287 test_file, owning_window, | 287 test_file, owning_window, |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 ASSERT_FALSE(second_dialog_->IsRunning(owning_window)); | 365 ASSERT_FALSE(second_dialog_->IsRunning(owning_window)); |
| 366 | 366 |
| 367 // Click cancel button. | 367 // Click cancel button. |
| 368 CloseDialog(DIALOG_BTN_CANCEL, owning_window); | 368 CloseDialog(DIALOG_BTN_CANCEL, owning_window); |
| 369 | 369 |
| 370 // Listener should have been informed of the cancellation. | 370 // Listener should have been informed of the cancellation. |
| 371 ASSERT_FALSE(listener_->file_selected()); | 371 ASSERT_FALSE(listener_->file_selected()); |
| 372 ASSERT_TRUE(listener_->canceled()); | 372 ASSERT_TRUE(listener_->canceled()); |
| 373 ASSERT_EQ(this, listener_->params()); | 373 ASSERT_EQ(this, listener_->params()); |
| 374 } | 374 } |
| OLD | NEW |