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/base/dialogs/select_file_dialog.h" | 29 #include "ui/base/dialogs/select_file_dialog.h" |
30 #include "ui/base/dialogs/selected_file_info.h" | 30 #include "ui/base/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 fileapi::ExternalMountPoints::GetSystemInstance()->RevokeFileSystem( | |
125 "Downloads"); | |
kinuko
2013/01/08 12:22:43
nit: This hard-coded string may look less nicer. W
tbarzic
2013/01/09 01:26:34
Done.
| |
126 ASSERT_TRUE(provider->AddLocalMountPoint(path)); | |
123 } | 127 } |
124 | 128 |
125 void CheckJavascriptErrors() { | 129 void CheckJavascriptErrors() { |
126 content::RenderViewHost* host = dialog_->GetRenderViewHost(); | 130 content::RenderViewHost* host = dialog_->GetRenderViewHost(); |
127 scoped_ptr<base::Value> value(host->ExecuteJavascriptAndGetValue( | 131 scoped_ptr<base::Value> value(host->ExecuteJavascriptAndGetValue( |
128 string16(), | 132 string16(), |
129 ASCIIToUTF16("window.JSErrorCount"))); | 133 ASCIIToUTF16("window.JSErrorCount"))); |
130 int js_error_count = 0; | 134 int js_error_count = 0; |
131 ASSERT_TRUE(value->GetAsInteger(&js_error_count)); | 135 ASSERT_TRUE(value->GetAsInteger(&js_error_count)); |
132 ASSERT_EQ(0, js_error_count); | 136 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)); | 364 ASSERT_FALSE(second_dialog_->IsRunning(owning_window)); |
361 | 365 |
362 // Click cancel button. | 366 // Click cancel button. |
363 CloseDialog(DIALOG_BTN_CANCEL, owning_window); | 367 CloseDialog(DIALOG_BTN_CANCEL, owning_window); |
364 | 368 |
365 // Listener should have been informed of the cancellation. | 369 // Listener should have been informed of the cancellation. |
366 ASSERT_FALSE(listener_->file_selected()); | 370 ASSERT_FALSE(listener_->file_selected()); |
367 ASSERT_TRUE(listener_->canceled()); | 371 ASSERT_TRUE(listener_->canceled()); |
368 ASSERT_EQ(this, listener_->params()); | 372 ASSERT_EQ(this, listener_->params()); |
369 } | 373 } |
OLD | NEW |