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

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

Issue 10698053: Breaks compile on Linux Aura (Closed) Base URL: svn://svn.chromium.org/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"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 class SelectFileDialogExtensionBrowserTest : public ExtensionBrowserTest { 75 class SelectFileDialogExtensionBrowserTest : public ExtensionBrowserTest {
76 public: 76 public:
77 enum DialogButtonType { 77 enum DialogButtonType {
78 DIALOG_BTN_OK, 78 DIALOG_BTN_OK,
79 DIALOG_BTN_CANCEL 79 DIALOG_BTN_CANCEL
80 }; 80 };
81 81
82 virtual void SetUp() OVERRIDE { 82 virtual void SetUp() OVERRIDE {
83 // Create the dialog wrapper object, but don't show it yet. 83 // Create the dialog wrapper object, but don't show it yet.
84 listener_.reset(new MockSelectFileDialogListener()); 84 listener_.reset(new MockSelectFileDialogListener());
85 dialog_ = new SelectFileDialogExtension(listener_.get(), NULL); 85 dialog_ = new SelectFileDialogExtension(listener_.get());
86 86
87 // We have to provide at least one mount point. 87 // We have to provide at least one mount point.
88 // File manager looks for "Downloads" mount point, so use this name. 88 // File manager looks for "Downloads" mount point, so use this name.
89 FilePath tmp_path; 89 FilePath tmp_path;
90 PathService::Get(base::DIR_TEMP, &tmp_path); 90 PathService::Get(base::DIR_TEMP, &tmp_path);
91 ASSERT_TRUE(tmp_dir_.CreateUniqueTempDirUnderPath(tmp_path)); 91 ASSERT_TRUE(tmp_dir_.CreateUniqueTempDirUnderPath(tmp_path));
92 downloads_dir_ = tmp_dir_.path().Append("Downloads"); 92 downloads_dir_ = tmp_dir_.path().Append("Downloads");
93 file_util::CreateDirectory(downloads_dir_); 93 file_util::CreateDirectory(downloads_dir_);
94 94
95 // Must run after our setup because it actually runs the test. 95 // Must run after our setup because it actually runs the test.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 additional_listener.reset( 129 additional_listener.reset(
130 new ExtensionTestMessageListener(additional_message, false)); 130 new ExtensionTestMessageListener(additional_message, false));
131 } 131 }
132 132
133 dialog_->SelectFile(dialog_type, 133 dialog_->SelectFile(dialog_type,
134 string16() /* title */, 134 string16() /* title */,
135 file_path, 135 file_path,
136 NULL /* file_types */, 136 NULL /* file_types */,
137 0 /* file_type_index */, 137 0 /* file_type_index */,
138 FILE_PATH_LITERAL("") /* default_extension */, 138 FILE_PATH_LITERAL("") /* default_extension */,
139 NULL /* source_contents */,
139 owning_window, 140 owning_window,
140 this /* params */); 141 this /* params */);
141 142
142 LOG(INFO) << "Waiting for JavaScript ready message."; 143 LOG(INFO) << "Waiting for JavaScript ready message.";
143 ASSERT_TRUE(init_listener.WaitUntilSatisfied()); 144 ASSERT_TRUE(init_listener.WaitUntilSatisfied());
144 145
145 if (additional_listener.get()) { 146 if (additional_listener.get()) {
146 LOG(INFO) << "Waiting for JavaScript " << additional_message 147 LOG(INFO) << "Waiting for JavaScript " << additional_message
147 << " message."; 148 << " message.";
148 ASSERT_TRUE(additional_listener->WaitUntilSatisfied()); 149 ASSERT_TRUE(additional_listener->WaitUntilSatisfied());
149 } 150 }
150 151
151 // Dialog should be running now. 152 // Dialog should be running now.
152 ASSERT_TRUE(dialog_->IsRunning(owning_window)); 153 ASSERT_TRUE(dialog_->IsRunning(owning_window));
153 } 154 }
154 155
155 void TryOpeningSecondDialog(const gfx::NativeWindow& owning_window) { 156 void TryOpeningSecondDialog(const gfx::NativeWindow& owning_window) {
156 second_listener_.reset(new MockSelectFileDialogListener()); 157 second_listener_.reset(new MockSelectFileDialogListener());
157 second_dialog_ = new SelectFileDialogExtension(second_listener_.get(), 158 second_dialog_ = new SelectFileDialogExtension(second_listener_.get());
158 NULL);
159 159
160 // At the moment we don't really care about dialog type, but we have to put 160 // At the moment we don't really care about dialog type, but we have to put
161 // some dialog type. 161 // some dialog type.
162 second_dialog_->SelectFile(SelectFileDialog::SELECT_OPEN_FILE, 162 second_dialog_->SelectFile(SelectFileDialog::SELECT_OPEN_FILE,
163 string16() /* title */, 163 string16() /* title */,
164 FilePath() /* default_path */, 164 FilePath() /* default_path */,
165 NULL /* file_types */, 165 NULL /* file_types */,
166 0 /* file_type_index */, 166 0 /* file_type_index */,
167 FILE_PATH_LITERAL("") /* default_extension */, 167 FILE_PATH_LITERAL("") /* default_extension */,
168 NULL /* source_contents */,
168 owning_window, 169 owning_window,
169 this /* params */); 170 this /* params */);
171
172
170 } 173 }
171 174
172 void CloseDialog(DialogButtonType button_type, 175 void CloseDialog(DialogButtonType button_type,
173 const gfx::NativeWindow& owning_window) { 176 const gfx::NativeWindow& owning_window) {
174 // Inject JavaScript to click the cancel button and wait for notification 177 // Inject JavaScript to click the cancel button and wait for notification
175 // that the window has closed. 178 // that the window has closed.
176 ui_test_utils::WindowedNotificationObserver host_destroyed( 179 ui_test_utils::WindowedNotificationObserver host_destroyed(
177 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, 180 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED,
178 content::NotificationService::AllSources()); 181 content::NotificationService::AllSources());
179 content::RenderViewHost* host = dialog_->GetRenderViewHost(); 182 content::RenderViewHost* host = dialog_->GetRenderViewHost();
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 ASSERT_FALSE(second_dialog_->IsRunning(owning_window)); 339 ASSERT_FALSE(second_dialog_->IsRunning(owning_window));
337 340
338 // Click cancel button. 341 // Click cancel button.
339 CloseDialog(DIALOG_BTN_CANCEL, owning_window); 342 CloseDialog(DIALOG_BTN_CANCEL, owning_window);
340 343
341 // Listener should have been informed of the cancellation. 344 // Listener should have been informed of the cancellation.
342 ASSERT_FALSE(listener_->file_selected()); 345 ASSERT_FALSE(listener_->file_selected());
343 ASSERT_TRUE(listener_->canceled()); 346 ASSERT_TRUE(listener_->canceled());
344 ASSERT_EQ(this, listener_->params()); 347 ASSERT_EQ(this, listener_->params());
345 } 348 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698