| 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/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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 this /* params */); | 123 this /* params */); |
| 124 LOG(INFO) << "Waiting for JavaScript ready message."; | 124 LOG(INFO) << "Waiting for JavaScript ready message."; |
| 125 ASSERT_TRUE(msg_listener.WaitUntilSatisfied()); | 125 ASSERT_TRUE(msg_listener.WaitUntilSatisfied()); |
| 126 | 126 |
| 127 // Dialog should be running now. | 127 // Dialog should be running now. |
| 128 ASSERT_TRUE(dialog_->IsRunning(owning_window)); | 128 ASSERT_TRUE(dialog_->IsRunning(owning_window)); |
| 129 | 129 |
| 130 // Inject JavaScript to click the cancel button and wait for notification | 130 // Inject JavaScript to click the cancel button and wait for notification |
| 131 // that the window has closed. | 131 // that the window has closed. |
| 132 ui_test_utils::WindowedNotificationObserver host_destroyed( | 132 ui_test_utils::WindowedNotificationObserver host_destroyed( |
| 133 NotificationType::RENDER_WIDGET_HOST_DESTROYED, | 133 chrome::RENDER_WIDGET_HOST_DESTROYED, |
| 134 NotificationService::AllSources()); | 134 NotificationService::AllSources()); |
| 135 RenderViewHost* host = dialog_->GetRenderViewHost(); | 135 RenderViewHost* host = dialog_->GetRenderViewHost(); |
| 136 string16 main_frame; | 136 string16 main_frame; |
| 137 string16 script = ASCIIToUTF16( | 137 string16 script = ASCIIToUTF16( |
| 138 "console.log(\'Test JavaScript injected.\');" | 138 "console.log(\'Test JavaScript injected.\');" |
| 139 "document.querySelector(\'.cancel\').click();"); | 139 "document.querySelector(\'.cancel\').click();"); |
| 140 // The file selection handler closes the dialog and does not return control | 140 // The file selection handler closes the dialog and does not return control |
| 141 // to JavaScript, so do not wait for return values. | 141 // to JavaScript, so do not wait for return values. |
| 142 host->ExecuteJavascriptInWebFrame(main_frame, script); | 142 host->ExecuteJavascriptInWebFrame(main_frame, script); |
| 143 LOG(INFO) << "Waiting for window close notification."; | 143 LOG(INFO) << "Waiting for window close notification."; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 this /* params */); | 187 this /* params */); |
| 188 LOG(INFO) << "Waiting for JavaScript selection-change-complete message."; | 188 LOG(INFO) << "Waiting for JavaScript selection-change-complete message."; |
| 189 ASSERT_TRUE(msg_listener.WaitUntilSatisfied()); | 189 ASSERT_TRUE(msg_listener.WaitUntilSatisfied()); |
| 190 | 190 |
| 191 // Dialog should be running now. | 191 // Dialog should be running now. |
| 192 ASSERT_TRUE(dialog_->IsRunning(owning_window)); | 192 ASSERT_TRUE(dialog_->IsRunning(owning_window)); |
| 193 | 193 |
| 194 // Inject JavaScript to click the open button and wait for notification | 194 // Inject JavaScript to click the open button and wait for notification |
| 195 // that the window has closed. | 195 // that the window has closed. |
| 196 ui_test_utils::WindowedNotificationObserver host_destroyed( | 196 ui_test_utils::WindowedNotificationObserver host_destroyed( |
| 197 NotificationType::RENDER_WIDGET_HOST_DESTROYED, | 197 chrome::RENDER_WIDGET_HOST_DESTROYED, |
| 198 NotificationService::AllSources()); | 198 NotificationService::AllSources()); |
| 199 RenderViewHost* host = dialog_->GetRenderViewHost(); | 199 RenderViewHost* host = dialog_->GetRenderViewHost(); |
| 200 string16 main_frame; | 200 string16 main_frame; |
| 201 string16 script = ASCIIToUTF16( | 201 string16 script = ASCIIToUTF16( |
| 202 "console.log(\'Test JavaScript injected.\');" | 202 "console.log(\'Test JavaScript injected.\');" |
| 203 "document.querySelector('.ok').click();"); | 203 "document.querySelector('.ok').click();"); |
| 204 // The file selection handler closes the dialog and does not return control | 204 // The file selection handler closes the dialog and does not return control |
| 205 // to JavaScript, so do not wait for return values. | 205 // to JavaScript, so do not wait for return values. |
| 206 host->ExecuteJavascriptInWebFrame(main_frame, script); | 206 host->ExecuteJavascriptInWebFrame(main_frame, script); |
| 207 LOG(INFO) << "Waiting for window close notification."; | 207 LOG(INFO) << "Waiting for window close notification."; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 this /* params */); | 247 this /* params */); |
| 248 LOG(INFO) << "Waiting for JavaScript message."; | 248 LOG(INFO) << "Waiting for JavaScript message."; |
| 249 ASSERT_TRUE(msg_listener.WaitUntilSatisfied()); | 249 ASSERT_TRUE(msg_listener.WaitUntilSatisfied()); |
| 250 | 250 |
| 251 // Dialog should be running now. | 251 // Dialog should be running now. |
| 252 ASSERT_TRUE(dialog_->IsRunning(owning_window)); | 252 ASSERT_TRUE(dialog_->IsRunning(owning_window)); |
| 253 | 253 |
| 254 // Inject JavaScript to click the save button and wait for notification | 254 // Inject JavaScript to click the save button and wait for notification |
| 255 // that the window has closed. | 255 // that the window has closed. |
| 256 ui_test_utils::WindowedNotificationObserver host_destroyed( | 256 ui_test_utils::WindowedNotificationObserver host_destroyed( |
| 257 NotificationType::RENDER_WIDGET_HOST_DESTROYED, | 257 chrome::RENDER_WIDGET_HOST_DESTROYED, |
| 258 NotificationService::AllSources()); | 258 NotificationService::AllSources()); |
| 259 RenderViewHost* host = dialog_->GetRenderViewHost(); | 259 RenderViewHost* host = dialog_->GetRenderViewHost(); |
| 260 string16 main_frame; | 260 string16 main_frame; |
| 261 string16 script = ASCIIToUTF16( | 261 string16 script = ASCIIToUTF16( |
| 262 "console.log(\'Test JavaScript injected.\');" | 262 "console.log(\'Test JavaScript injected.\');" |
| 263 "document.querySelector('.ok').click();"); | 263 "document.querySelector('.ok').click();"); |
| 264 // The file selection handler closes the dialog and does not return control | 264 // The file selection handler closes the dialog and does not return control |
| 265 // to JavaScript, so do not wait for return values. | 265 // to JavaScript, so do not wait for return values. |
| 266 host->ExecuteJavascriptInWebFrame(main_frame, script); | 266 host->ExecuteJavascriptInWebFrame(main_frame, script); |
| 267 LOG(INFO) << "Waiting for window close notification."; | 267 LOG(INFO) << "Waiting for window close notification."; |
| 268 host_destroyed.Wait(); | 268 host_destroyed.Wait(); |
| 269 | 269 |
| 270 // Dialog no longer believes it is running. | 270 // Dialog no longer believes it is running. |
| 271 ASSERT_FALSE(dialog_->IsRunning(owning_window)); | 271 ASSERT_FALSE(dialog_->IsRunning(owning_window)); |
| 272 | 272 |
| 273 // Listener should have been informed that the file was selected. | 273 // Listener should have been informed that the file was selected. |
| 274 ASSERT_TRUE(listener_->file_selected()); | 274 ASSERT_TRUE(listener_->file_selected()); |
| 275 ASSERT_FALSE(listener_->canceled()); | 275 ASSERT_FALSE(listener_->canceled()); |
| 276 ASSERT_EQ(test_file, listener_->path()); | 276 ASSERT_EQ(test_file, listener_->path()); |
| 277 ASSERT_EQ(this, listener_->params()); | 277 ASSERT_EQ(this, listener_->params()); |
| 278 } | 278 } |
| OLD | NEW |