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

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

Issue 10807047: Create content\public\test\test_utils.h to hold common test classes that are used by unit and brows… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 5 months 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 | Annotate | Revision Log
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/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"
11 #include "base/scoped_temp_dir.h" 11 #include "base/scoped_temp_dir.h"
12 #include "base/threading/platform_thread.h" 12 #include "base/threading/platform_thread.h"
13 #include "base/utf_string_conversions.h" // ASCIIToUTF16 13 #include "base/utf_string_conversions.h" // ASCIIToUTF16
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "chrome/browser/extensions/extension_browsertest.h" 15 #include "chrome/browser/extensions/extension_browsertest.h"
16 #include "chrome/browser/extensions/extension_test_message_listener.h" 16 #include "chrome/browser/extensions/extension_test_message_listener.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
19 #include "chrome/browser/ui/browser_navigator.h" 19 #include "chrome/browser/ui/browser_navigator.h"
20 #include "chrome/browser/ui/browser_window.h" 20 #include "chrome/browser/ui/browser_window.h"
21 #include "chrome/browser/ui/select_file_dialog.h" 21 #include "chrome/browser/ui/select_file_dialog.h"
22 #include "chrome/common/chrome_paths.h" 22 #include "chrome/common/chrome_paths.h"
23 #include "chrome/test/base/ui_test_utils.h"
24 #include "content/public/browser/notification_service.h" 23 #include "content/public/browser/notification_service.h"
25 #include "content/public/browser/notification_types.h" 24 #include "content/public/browser/notification_types.h"
26 #include "content/public/browser/render_view_host.h" 25 #include "content/public/browser/render_view_host.h"
26 #include "content/public/test/test_utils.h"
27 #include "ui/base/dialogs/selected_file_info.h" 27 #include "ui/base/dialogs/selected_file_info.h"
28 #include "webkit/fileapi/file_system_context.h" 28 #include "webkit/fileapi/file_system_context.h"
29 #include "webkit/fileapi/file_system_mount_point_provider.h" 29 #include "webkit/fileapi/file_system_mount_point_provider.h"
30 30
31 using content::BrowserContext; 31 using content::BrowserContext;
32 32
33 // Mock listener used by test below. 33 // Mock listener used by test below.
34 class MockSelectFileDialogListener : public SelectFileDialog::Listener { 34 class MockSelectFileDialogListener : public SelectFileDialog::Listener {
35 public: 35 public:
36 MockSelectFileDialogListener() 36 MockSelectFileDialogListener()
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 0 /* file_type_index */, 166 0 /* file_type_index */,
167 FILE_PATH_LITERAL("") /* default_extension */, 167 FILE_PATH_LITERAL("") /* default_extension */,
168 owning_window, 168 owning_window,
169 this /* params */); 169 this /* params */);
170 } 170 }
171 171
172 void CloseDialog(DialogButtonType button_type, 172 void CloseDialog(DialogButtonType button_type,
173 const gfx::NativeWindow& owning_window) { 173 const gfx::NativeWindow& owning_window) {
174 // Inject JavaScript to click the cancel button and wait for notification 174 // Inject JavaScript to click the cancel button and wait for notification
175 // that the window has closed. 175 // that the window has closed.
176 ui_test_utils::WindowedNotificationObserver host_destroyed( 176 content::WindowedNotificationObserver host_destroyed(
177 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, 177 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED,
178 content::NotificationService::AllSources()); 178 content::NotificationService::AllSources());
179 content::RenderViewHost* host = dialog_->GetRenderViewHost(); 179 content::RenderViewHost* host = dialog_->GetRenderViewHost();
180 string16 main_frame; 180 string16 main_frame;
181 std::string button_class = 181 std::string button_class =
182 (button_type == DIALOG_BTN_OK) ? ".ok" : ".cancel"; 182 (button_type == DIALOG_BTN_OK) ? ".ok" : ".cancel";
183 string16 script = ASCIIToUTF16( 183 string16 script = ASCIIToUTF16(
184 "console.log(\'Test JavaScript injected.\');" 184 "console.log(\'Test JavaScript injected.\');"
185 "document.querySelector(\'" + button_class + "\').click();"); 185 "document.querySelector(\'" + button_class + "\').click();");
186 // The file selection handler closes the dialog and does not return control 186 // The file selection handler closes the dialog and does not return control
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 ASSERT_FALSE(second_dialog_->IsRunning(owning_window)); 336 ASSERT_FALSE(second_dialog_->IsRunning(owning_window));
337 337
338 // Click cancel button. 338 // Click cancel button.
339 CloseDialog(DIALOG_BTN_CANCEL, owning_window); 339 CloseDialog(DIALOG_BTN_CANCEL, owning_window);
340 340
341 // Listener should have been informed of the cancellation. 341 // Listener should have been informed of the cancellation.
342 ASSERT_FALSE(listener_->file_selected()); 342 ASSERT_FALSE(listener_->file_selected());
343 ASSERT_TRUE(listener_->canceled()); 343 ASSERT_TRUE(listener_->canceled());
344 ASSERT_EQ(this, listener_->params()); 344 ASSERT_EQ(this, listener_->params());
345 } 345 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/keyboard_access_browsertest.cc ('k') | chrome/browser/ui/webui/ntp/new_tab_ui_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698