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

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

Issue 8342048: Make NotificationService an interface in the content namespace, and switch callers to use it. Mov... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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) 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/file_manager_dialog.h" 5 #include "chrome/browser/ui/views/file_manager_dialog.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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 LOG(INFO) << "Waiting for JavaScript ready message."; 136 LOG(INFO) << "Waiting for JavaScript ready message.";
137 ASSERT_TRUE(init_listener.WaitUntilSatisfied()); 137 ASSERT_TRUE(init_listener.WaitUntilSatisfied());
138 138
139 // Dialog should be running now. 139 // Dialog should be running now.
140 ASSERT_TRUE(dialog_->IsRunning(owning_window)); 140 ASSERT_TRUE(dialog_->IsRunning(owning_window));
141 141
142 // Inject JavaScript to click the cancel button and wait for notification 142 // Inject JavaScript to click the cancel button and wait for notification
143 // that the window has closed. 143 // that the window has closed.
144 ui_test_utils::WindowedNotificationObserver host_destroyed( 144 ui_test_utils::WindowedNotificationObserver host_destroyed(
145 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, 145 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED,
146 NotificationService::AllSources()); 146 content::NotificationService::AllSources());
147 RenderViewHost* host = dialog_->GetRenderViewHost(); 147 RenderViewHost* host = dialog_->GetRenderViewHost();
148 string16 main_frame; 148 string16 main_frame;
149 string16 script = ASCIIToUTF16( 149 string16 script = ASCIIToUTF16(
150 "console.log(\'Test JavaScript injected.\');" 150 "console.log(\'Test JavaScript injected.\');"
151 "document.querySelector(\'.cancel\').click();"); 151 "document.querySelector(\'.cancel\').click();");
152 // The file selection handler closes the dialog and does not return control 152 // The file selection handler closes the dialog and does not return control
153 // to JavaScript, so do not wait for return values. 153 // to JavaScript, so do not wait for return values.
154 host->ExecuteJavascriptInWebFrame(main_frame, script); 154 host->ExecuteJavascriptInWebFrame(main_frame, script);
155 LOG(INFO) << "Waiting for window close notification."; 155 LOG(INFO) << "Waiting for window close notification.";
156 host_destroyed.Wait(); 156 host_destroyed.Wait();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 LOG(INFO) << "Waiting for JavaScript selection-change-complete message."; 206 LOG(INFO) << "Waiting for JavaScript selection-change-complete message.";
207 ASSERT_TRUE(selection_listener.WaitUntilSatisfied()); 207 ASSERT_TRUE(selection_listener.WaitUntilSatisfied());
208 208
209 // Dialog should be running now. 209 // Dialog should be running now.
210 ASSERT_TRUE(dialog_->IsRunning(owning_window)); 210 ASSERT_TRUE(dialog_->IsRunning(owning_window));
211 211
212 // Inject JavaScript to click the open button and wait for notification 212 // Inject JavaScript to click the open button and wait for notification
213 // that the window has closed. 213 // that the window has closed.
214 ui_test_utils::WindowedNotificationObserver host_destroyed( 214 ui_test_utils::WindowedNotificationObserver host_destroyed(
215 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, 215 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED,
216 NotificationService::AllSources()); 216 content::NotificationService::AllSources());
217 RenderViewHost* host = dialog_->GetRenderViewHost(); 217 RenderViewHost* host = dialog_->GetRenderViewHost();
218 string16 main_frame; 218 string16 main_frame;
219 string16 script = ASCIIToUTF16( 219 string16 script = ASCIIToUTF16(
220 "console.log(\'Test JavaScript injected.\');" 220 "console.log(\'Test JavaScript injected.\');"
221 "document.querySelector('.ok').click();"); 221 "document.querySelector('.ok').click();");
222 // The file selection handler closes the dialog and does not return control 222 // The file selection handler closes the dialog and does not return control
223 // to JavaScript, so do not wait for return values. 223 // to JavaScript, so do not wait for return values.
224 host->ExecuteJavascriptInWebFrame(main_frame, script); 224 host->ExecuteJavascriptInWebFrame(main_frame, script);
225 LOG(INFO) << "Waiting for window close notification."; 225 LOG(INFO) << "Waiting for window close notification.";
226 host_destroyed.Wait(); 226 host_destroyed.Wait();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 LOG(INFO) << "Waiting for JavaScript directory-change-complete message."; 272 LOG(INFO) << "Waiting for JavaScript directory-change-complete message.";
273 ASSERT_TRUE(dir_change_listener.WaitUntilSatisfied()); 273 ASSERT_TRUE(dir_change_listener.WaitUntilSatisfied());
274 274
275 // Dialog should be running now. 275 // Dialog should be running now.
276 ASSERT_TRUE(dialog_->IsRunning(owning_window)); 276 ASSERT_TRUE(dialog_->IsRunning(owning_window));
277 277
278 // Inject JavaScript to click the save button and wait for notification 278 // Inject JavaScript to click the save button and wait for notification
279 // that the window has closed. 279 // that the window has closed.
280 ui_test_utils::WindowedNotificationObserver host_destroyed( 280 ui_test_utils::WindowedNotificationObserver host_destroyed(
281 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, 281 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED,
282 NotificationService::AllSources()); 282 content::NotificationService::AllSources());
283 RenderViewHost* host = dialog_->GetRenderViewHost(); 283 RenderViewHost* host = dialog_->GetRenderViewHost();
284 string16 main_frame; 284 string16 main_frame;
285 string16 script = ASCIIToUTF16( 285 string16 script = ASCIIToUTF16(
286 "console.log(\'Test JavaScript injected.\');" 286 "console.log(\'Test JavaScript injected.\');"
287 "document.querySelector('.ok').click();"); 287 "document.querySelector('.ok').click();");
288 // The file selection handler closes the dialog and does not return control 288 // The file selection handler closes the dialog and does not return control
289 // to JavaScript, so do not wait for return values. 289 // to JavaScript, so do not wait for return values.
290 host->ExecuteJavascriptInWebFrame(main_frame, script); 290 host->ExecuteJavascriptInWebFrame(main_frame, script);
291 LOG(INFO) << "Waiting for window close notification."; 291 LOG(INFO) << "Waiting for window close notification.";
292 host_destroyed.Wait(); 292 host_destroyed.Wait();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 browser::NavigateParams p(browser(), GURL("www.google.com"), 333 browser::NavigateParams p(browser(), GURL("www.google.com"),
334 content::PAGE_TRANSITION_LINK); 334 content::PAGE_TRANSITION_LINK);
335 p.window_action = browser::NavigateParams::SHOW_WINDOW; 335 p.window_action = browser::NavigateParams::SHOW_WINDOW;
336 p.disposition = SINGLETON_TAB; 336 p.disposition = SINGLETON_TAB;
337 browser::Navigate(&p); 337 browser::Navigate(&p);
338 338
339 // Inject JavaScript to click the cancel button and wait for notification 339 // Inject JavaScript to click the cancel button and wait for notification
340 // that the window has closed. 340 // that the window has closed.
341 ui_test_utils::WindowedNotificationObserver host_destroyed( 341 ui_test_utils::WindowedNotificationObserver host_destroyed(
342 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, 342 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED,
343 NotificationService::AllSources()); 343 content::NotificationService::AllSources());
344 RenderViewHost* host = dialog_->GetRenderViewHost(); 344 RenderViewHost* host = dialog_->GetRenderViewHost();
345 string16 main_frame; 345 string16 main_frame;
346 string16 script = ASCIIToUTF16( 346 string16 script = ASCIIToUTF16(
347 "console.log(\'Test JavaScript injected.\');" 347 "console.log(\'Test JavaScript injected.\');"
348 "document.querySelector(\'.cancel\').click();"); 348 "document.querySelector(\'.cancel\').click();");
349 // The file selection handler closes the dialog and does not return control 349 // The file selection handler closes the dialog and does not return control
350 // to JavaScript, so do not wait for return values. 350 // to JavaScript, so do not wait for return values.
351 host->ExecuteJavascriptInWebFrame(main_frame, script); 351 host->ExecuteJavascriptInWebFrame(main_frame, script);
352 LOG(INFO) << "Waiting for window close notification."; 352 LOG(INFO) << "Waiting for window close notification.";
353 host_destroyed.Wait(); 353 host_destroyed.Wait();
354 354
355 // Dialog no longer believes it is running. 355 // Dialog no longer believes it is running.
356 ASSERT_FALSE(dialog_->IsRunning(owning_window)); 356 ASSERT_FALSE(dialog_->IsRunning(owning_window));
357 357
358 // Listener should have been informed of the cancellation. 358 // Listener should have been informed of the cancellation.
359 ASSERT_FALSE(listener_->file_selected()); 359 ASSERT_FALSE(listener_->file_selected());
360 ASSERT_TRUE(listener_->canceled()); 360 ASSERT_TRUE(listener_->canceled());
361 ASSERT_EQ(this, listener_->params()); 361 ASSERT_EQ(this, listener_->params());
362 } 362 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698