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" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/threading/platform_thread.h" | 12 #include "base/threading/platform_thread.h" |
13 #include "base/utf_string_conversions.h" // ASCIIToUTF16 | 13 #include "base/utf_string_conversions.h" // ASCIIToUTF16 |
14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "chrome/browser/extensions/component_loader.h" |
15 #include "chrome/browser/extensions/extension_browsertest.h" | 16 #include "chrome/browser/extensions/extension_browsertest.h" |
16 #include "chrome/browser/extensions/extension_test_message_listener.h" | 17 #include "chrome/browser/extensions/extension_test_message_listener.h" |
17 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
19 #include "chrome/browser/ui/browser_navigator.h" | 20 #include "chrome/browser/ui/browser_navigator.h" |
20 #include "chrome/browser/ui/browser_window.h" | 21 #include "chrome/browser/ui/browser_window.h" |
21 #include "chrome/common/chrome_paths.h" | 22 #include "chrome/common/chrome_paths.h" |
22 #include "content/public/browser/browser_context.h" | 23 #include "content/public/browser/browser_context.h" |
23 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
24 #include "content/public/browser/notification_types.h" | 25 #include "content/public/browser/notification_types.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 }; | 78 }; |
78 | 79 |
79 class SelectFileDialogExtensionBrowserTest : public ExtensionBrowserTest { | 80 class SelectFileDialogExtensionBrowserTest : public ExtensionBrowserTest { |
80 public: | 81 public: |
81 enum DialogButtonType { | 82 enum DialogButtonType { |
82 DIALOG_BTN_OK, | 83 DIALOG_BTN_OK, |
83 DIALOG_BTN_CANCEL | 84 DIALOG_BTN_CANCEL |
84 }; | 85 }; |
85 | 86 |
86 virtual void SetUp() OVERRIDE { | 87 virtual void SetUp() OVERRIDE { |
| 88 extensions::ComponentLoader::EnableBackgroundExtensionsForTesting(); |
| 89 |
87 // Create the dialog wrapper object, but don't show it yet. | 90 // Create the dialog wrapper object, but don't show it yet. |
88 listener_.reset(new MockSelectFileDialogListener()); | 91 listener_.reset(new MockSelectFileDialogListener()); |
89 dialog_ = new SelectFileDialogExtension(listener_.get(), NULL); | 92 dialog_ = new SelectFileDialogExtension(listener_.get(), NULL); |
90 | 93 |
91 // We have to provide at least one mount point. | 94 // We have to provide at least one mount point. |
92 // File manager looks for "Downloads" mount point, so use this name. | 95 // File manager looks for "Downloads" mount point, so use this name. |
93 FilePath tmp_path; | 96 FilePath tmp_path; |
94 PathService::Get(base::DIR_TEMP, &tmp_path); | 97 PathService::Get(base::DIR_TEMP, &tmp_path); |
95 ASSERT_TRUE(tmp_dir_.CreateUniqueTempDirUnderPath(tmp_path)); | 98 ASSERT_TRUE(tmp_dir_.CreateUniqueTempDirUnderPath(tmp_path)); |
96 downloads_dir_ = tmp_dir_.path().Append("Downloads"); | 99 downloads_dir_ = tmp_dir_.path().Append("Downloads"); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 ASSERT_FALSE(second_dialog_->IsRunning(owning_window)); | 346 ASSERT_FALSE(second_dialog_->IsRunning(owning_window)); |
344 | 347 |
345 // Click cancel button. | 348 // Click cancel button. |
346 CloseDialog(DIALOG_BTN_CANCEL, owning_window); | 349 CloseDialog(DIALOG_BTN_CANCEL, owning_window); |
347 | 350 |
348 // Listener should have been informed of the cancellation. | 351 // Listener should have been informed of the cancellation. |
349 ASSERT_FALSE(listener_->file_selected()); | 352 ASSERT_FALSE(listener_->file_selected()); |
350 ASSERT_TRUE(listener_->canceled()); | 353 ASSERT_TRUE(listener_->canceled()); |
351 ASSERT_EQ(this, listener_->params()); | 354 ASSERT_EQ(this, listener_->params()); |
352 } | 355 } |
OLD | NEW |