Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Side by Side Diff: chrome/browser/ui/views/select_file_dialog_extension_browsertest.cc

Issue 736663002: Refoctoring FileSelection and FileSelectionHandler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/file_manager/file_manager/foreground/js/dialog_action_controller.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/files/file_util.h" 7 #include "base/files/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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 ASSERT_TRUE(fp != NULL); 272 ASSERT_TRUE(fp != NULL);
273 ASSERT_TRUE(base::CloseFile(fp)); 273 ASSERT_TRUE(base::CloseFile(fp));
274 274
275 gfx::NativeWindow owning_window = browser()->window()->GetNativeWindow(); 275 gfx::NativeWindow owning_window = browser()->window()->GetNativeWindow();
276 276
277 // Spawn a dialog to open a file. Provide the path to the file so the dialog 277 // Spawn a dialog to open a file. Provide the path to the file so the dialog
278 // will automatically select it. Ensure that the OK button is enabled by 278 // will automatically select it. Ensure that the OK button is enabled by
279 // waiting for chrome.test.sendMessage('selection-change-complete'). 279 // waiting for chrome.test.sendMessage('selection-change-complete').
280 ASSERT_NO_FATAL_FAILURE(OpenDialog(ui::SelectFileDialog::SELECT_OPEN_FILE, 280 ASSERT_NO_FATAL_FAILURE(OpenDialog(ui::SelectFileDialog::SELECT_OPEN_FILE,
281 test_file, owning_window, 281 test_file, owning_window,
282 "selection-change-complete")); 282 "dialog-ready"));
283 283
284 // Click open button. 284 // Click open button.
285 CloseDialog(DIALOG_BTN_OK, owning_window); 285 CloseDialog(DIALOG_BTN_OK, owning_window);
286 286
287 // Listener should have been informed that the file was opened. 287 // Listener should have been informed that the file was opened.
288 ASSERT_TRUE(listener_->file_selected()); 288 ASSERT_TRUE(listener_->file_selected());
289 ASSERT_FALSE(listener_->canceled()); 289 ASSERT_FALSE(listener_->canceled());
290 ASSERT_EQ(test_file, listener_->path()); 290 ASSERT_EQ(test_file, listener_->path());
291 ASSERT_EQ(this, listener_->params()); 291 ASSERT_EQ(this, listener_->params());
292 } 292 }
293 293
294 IN_PROC_BROWSER_TEST_F(SelectFileDialogExtensionBrowserTest, 294 IN_PROC_BROWSER_TEST_F(SelectFileDialogExtensionBrowserTest,
295 SelectFileAndSave) { 295 SelectFileAndSave) {
296 AddMountPoint(downloads_dir_); 296 AddMountPoint(downloads_dir_);
297 297
298 base::FilePath test_file = 298 base::FilePath test_file =
299 downloads_dir_.AppendASCII("file_manager_test.html"); 299 downloads_dir_.AppendASCII("file_manager_test.html");
300 300
301 gfx::NativeWindow owning_window = browser()->window()->GetNativeWindow(); 301 gfx::NativeWindow owning_window = browser()->window()->GetNativeWindow();
302 302
303 // Spawn a dialog to save a file, providing a suggested path. 303 // Spawn a dialog to save a file, providing a suggested path.
304 // Ensure "Save" button is enabled by waiting for notification from 304 // Ensure "Save" button is enabled by waiting for notification from
305 // chrome.test.sendMessage(). 305 // chrome.test.sendMessage().
306 ASSERT_NO_FATAL_FAILURE(OpenDialog(ui::SelectFileDialog::SELECT_SAVEAS_FILE, 306 ASSERT_NO_FATAL_FAILURE(OpenDialog(ui::SelectFileDialog::SELECT_SAVEAS_FILE,
307 test_file, owning_window, 307 test_file, owning_window,
308 "directory-change-complete")); 308 "dialog-ready"));
309 309
310 // Click save button. 310 // Click save button.
311 CloseDialog(DIALOG_BTN_OK, owning_window); 311 CloseDialog(DIALOG_BTN_OK, owning_window);
312 312
313 // Listener should have been informed that the file was selected. 313 // Listener should have been informed that the file was selected.
314 ASSERT_TRUE(listener_->file_selected()); 314 ASSERT_TRUE(listener_->file_selected());
315 ASSERT_FALSE(listener_->canceled()); 315 ASSERT_FALSE(listener_->canceled());
316 ASSERT_EQ(test_file, listener_->path()); 316 ASSERT_EQ(test_file, listener_->path());
317 ASSERT_EQ(this, listener_->params()); 317 ASSERT_EQ(this, listener_->params());
318 } 318 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 ASSERT_FALSE(second_dialog_->IsRunning(owning_window)); 357 ASSERT_FALSE(second_dialog_->IsRunning(owning_window));
358 358
359 // Click cancel button. 359 // Click cancel button.
360 CloseDialog(DIALOG_BTN_CANCEL, owning_window); 360 CloseDialog(DIALOG_BTN_CANCEL, owning_window);
361 361
362 // Listener should have been informed of the cancellation. 362 // Listener should have been informed of the cancellation.
363 ASSERT_FALSE(listener_->file_selected()); 363 ASSERT_FALSE(listener_->file_selected());
364 ASSERT_TRUE(listener_->canceled()); 364 ASSERT_TRUE(listener_->canceled());
365 ASSERT_EQ(this, listener_->params()); 365 ASSERT_EQ(this, listener_->params());
366 } 366 }
OLDNEW
« no previous file with comments | « no previous file | ui/file_manager/file_manager/foreground/js/dialog_action_controller.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698