OLD | NEW |
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/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 10 matching lines...) Expand all Loading... |
21 #include "chrome/browser/ui/browser_window.h" | 21 #include "chrome/browser/ui/browser_window.h" |
22 #include "chrome/common/chrome_paths.h" | 22 #include "chrome/common/chrome_paths.h" |
23 #include "content/public/browser/browser_context.h" | 23 #include "content/public/browser/browser_context.h" |
24 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
25 #include "content/public/browser/notification_types.h" | 25 #include "content/public/browser/notification_types.h" |
26 #include "content/public/browser/render_view_host.h" | 26 #include "content/public/browser/render_view_host.h" |
27 #include "content/public/browser/storage_partition.h" | 27 #include "content/public/browser/storage_partition.h" |
28 #include "content/public/test/test_utils.h" | 28 #include "content/public/test/test_utils.h" |
29 #include "ui/shell_dialogs/select_file_dialog.h" | 29 #include "ui/shell_dialogs/select_file_dialog.h" |
30 #include "ui/shell_dialogs/selected_file_info.h" | 30 #include "ui/shell_dialogs/selected_file_info.h" |
| 31 #include "webkit/fileapi/external_mount_points.h" |
31 #include "webkit/fileapi/file_system_context.h" | 32 #include "webkit/fileapi/file_system_context.h" |
32 #include "webkit/fileapi/file_system_mount_point_provider.h" | 33 #include "webkit/fileapi/file_system_mount_point_provider.h" |
33 | 34 |
34 using content::BrowserContext; | 35 using content::BrowserContext; |
35 | 36 |
36 // Mock listener used by test below. | 37 // Mock listener used by test below. |
37 class MockSelectFileDialogListener : public ui::SelectFileDialog::Listener { | 38 class MockSelectFileDialogListener : public ui::SelectFileDialog::Listener { |
38 public: | 39 public: |
39 MockSelectFileDialogListener() | 40 MockSelectFileDialogListener() |
40 : file_selected_(false), | 41 : file_selected_(false), |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 113 |
113 second_dialog_ = NULL; | 114 second_dialog_ = NULL; |
114 second_listener_.reset(); | 115 second_listener_.reset(); |
115 } | 116 } |
116 | 117 |
117 // Creates a file system mount point for a directory. | 118 // Creates a file system mount point for a directory. |
118 void AddMountPoint(const FilePath& path) { | 119 void AddMountPoint(const FilePath& path) { |
119 fileapi::ExternalFileSystemMountPointProvider* provider = | 120 fileapi::ExternalFileSystemMountPointProvider* provider = |
120 BrowserContext::GetDefaultStoragePartition(browser()->profile())-> | 121 BrowserContext::GetDefaultStoragePartition(browser()->profile())-> |
121 GetFileSystemContext()->external_provider(); | 122 GetFileSystemContext()->external_provider(); |
122 provider->AddLocalMountPoint(path); | 123 |
| 124 // The Downloads mount point already exists so it must be removed before |
| 125 // adding the test mount point (which will also be mapped as Downloads). |
| 126 fileapi::ExternalMountPoints::GetSystemInstance()->RevokeFileSystem( |
| 127 path.BaseName().AsUTF8Unsafe()); |
| 128 EXPECT_TRUE(provider->AddLocalMountPoint(path)); |
123 } | 129 } |
124 | 130 |
125 void CheckJavascriptErrors() { | 131 void CheckJavascriptErrors() { |
126 content::RenderViewHost* host = dialog_->GetRenderViewHost(); | 132 content::RenderViewHost* host = dialog_->GetRenderViewHost(); |
127 scoped_ptr<base::Value> value(host->ExecuteJavascriptAndGetValue( | 133 scoped_ptr<base::Value> value(host->ExecuteJavascriptAndGetValue( |
128 string16(), | 134 string16(), |
129 ASCIIToUTF16("window.JSErrorCount"))); | 135 ASCIIToUTF16("window.JSErrorCount"))); |
130 int js_error_count = 0; | 136 int js_error_count = 0; |
131 ASSERT_TRUE(value->GetAsInteger(&js_error_count)); | 137 ASSERT_TRUE(value->GetAsInteger(&js_error_count)); |
132 ASSERT_EQ(0, js_error_count); | 138 ASSERT_EQ(0, js_error_count); |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 ASSERT_FALSE(second_dialog_->IsRunning(owning_window)); | 366 ASSERT_FALSE(second_dialog_->IsRunning(owning_window)); |
361 | 367 |
362 // Click cancel button. | 368 // Click cancel button. |
363 CloseDialog(DIALOG_BTN_CANCEL, owning_window); | 369 CloseDialog(DIALOG_BTN_CANCEL, owning_window); |
364 | 370 |
365 // Listener should have been informed of the cancellation. | 371 // Listener should have been informed of the cancellation. |
366 ASSERT_FALSE(listener_->file_selected()); | 372 ASSERT_FALSE(listener_->file_selected()); |
367 ASSERT_TRUE(listener_->canceled()); | 373 ASSERT_TRUE(listener_->canceled()); |
368 ASSERT_EQ(this, listener_->params()); | 374 ASSERT_EQ(this, listener_->params()); |
369 } | 375 } |
OLD | NEW |