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

Side by Side Diff: chrome/browser/ui/chrome_select_file_policy_unittest.cc

Issue 10820034: Remove redirection header and add "ui::" before all SelectFileDialog usage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reuploading for different try run. Created 8 years, 4 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
« no previous file with comments | « chrome/browser/ui/certificate_dialogs.cc ('k') | chrome/browser/ui/select_file_dialog.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/chrome_select_file_policy.h" 5 #include "chrome/browser/ui/chrome_select_file_policy.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/prefs/browser_prefs.h" 13 #include "chrome/browser/prefs/browser_prefs.h"
14 #include "chrome/browser/prefs/pref_service.h" 14 #include "chrome/browser/prefs/pref_service.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/select_file_dialog.h"
17 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
18 #include "chrome/test/base/testing_browser_process.h" 17 #include "chrome/test/base/testing_browser_process.h"
19 #include "chrome/test/base/testing_pref_service.h" 18 #include "chrome/test/base/testing_pref_service.h"
20 #include "content/public/test/test_browser_thread.h" 19 #include "content/public/test/test_browser_thread.h"
21 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
21 #include "ui/base/dialogs/select_file_dialog.h"
22 22
23 #if defined(USE_AURA) 23 #if defined(USE_AURA)
24 // http://crbug.com/105200 24 // http://crbug.com/105200
25 #define MAYBE_ExpectAsynchronousListenerCall DISABLED_ExpectAsynchronousListener Call 25 #define MAYBE_ExpectAsynchronousListenerCall DISABLED_ExpectAsynchronousListener Call
26 #else 26 #else
27 #define MAYBE_ExpectAsynchronousListenerCall ExpectAsynchronousListenerCall 27 #define MAYBE_ExpectAsynchronousListenerCall ExpectAsynchronousListenerCall
28 #endif 28 #endif
29 29
30 using content::BrowserThread; 30 using content::BrowserThread;
31 31
32 namespace { 32 namespace {
33 33
34 class FileSelectionUser : public SelectFileDialog::Listener { 34 class FileSelectionUser : public ui::SelectFileDialog::Listener {
35 public: 35 public:
36 FileSelectionUser() 36 FileSelectionUser()
37 : file_selection_initialisation_in_progress(false) { 37 : file_selection_initialisation_in_progress(false) {
38 } 38 }
39 39
40 ~FileSelectionUser() { 40 ~FileSelectionUser() {
41 if (select_file_dialog_.get()) 41 if (select_file_dialog_.get())
42 select_file_dialog_->ListenerDestroyed(); 42 select_file_dialog_->ListenerDestroyed();
43 } 43 }
44 44
45 void StartFileSelection() { 45 void StartFileSelection() {
46 CHECK(!select_file_dialog_.get()); 46 CHECK(!select_file_dialog_.get());
47 select_file_dialog_ = SelectFileDialog::Create( 47 select_file_dialog_ = ui::SelectFileDialog::Create(
48 this, new ChromeSelectFilePolicy(NULL)); 48 this, new ChromeSelectFilePolicy(NULL));
49 49
50 const FilePath file_path; 50 const FilePath file_path;
51 const string16 title=string16(); 51 const string16 title=string16();
52 52
53 file_selection_initialisation_in_progress = true; 53 file_selection_initialisation_in_progress = true;
54 select_file_dialog_->SelectFile(SelectFileDialog::SELECT_OPEN_FILE, 54 select_file_dialog_->SelectFile(ui::SelectFileDialog::SELECT_OPEN_FILE,
55 title, 55 title,
56 file_path, 56 file_path,
57 NULL, 57 NULL,
58 0, 58 0,
59 FILE_PATH_LITERAL(""), 59 FILE_PATH_LITERAL(""),
60 NULL, 60 NULL,
61 NULL); 61 NULL);
62 file_selection_initialisation_in_progress = false; 62 file_selection_initialisation_in_progress = false;
63 } 63 }
64 64
65 // SelectFileDialog::Listener implementation. 65 // ui::SelectFileDialog::Listener implementation.
66 virtual void FileSelected(const FilePath& path, 66 virtual void FileSelected(const FilePath& path,
67 int index, void* params){ 67 int index, void* params){
68 ASSERT_FALSE(file_selection_initialisation_in_progress); 68 ASSERT_FALSE(file_selection_initialisation_in_progress);
69 } 69 }
70 virtual void MultiFilesSelected( 70 virtual void MultiFilesSelected(
71 const std::vector<FilePath>& files, 71 const std::vector<FilePath>& files,
72 void* params) { 72 void* params) {
73 ASSERT_FALSE(file_selection_initialisation_in_progress); 73 ASSERT_FALSE(file_selection_initialisation_in_progress);
74 } 74 }
75 virtual void FileSelectionCanceled(void* params) { 75 virtual void FileSelectionCanceled(void* params) {
76 ASSERT_FALSE(file_selection_initialisation_in_progress); 76 ASSERT_FALSE(file_selection_initialisation_in_progress);
77 } 77 }
78 78
79 private: 79 private:
80 scoped_refptr<SelectFileDialog> select_file_dialog_; 80 scoped_refptr<ui::SelectFileDialog> select_file_dialog_;
81 81
82 bool file_selection_initialisation_in_progress; 82 bool file_selection_initialisation_in_progress;
83 }; 83 };
84 84
85 } // namespace 85 } // namespace
86 86
87 typedef testing::Test ChromeSelectFilePolicyTest; 87 typedef testing::Test ChromeSelectFilePolicyTest;
88 88
89 // Tests if SelectFileDialog::SelectFile returns asynchronously with 89 // Tests if SelectFileDialog::SelectFile returns asynchronously with
90 // file-selection dialogs disabled by policy. 90 // file-selection dialogs disabled by policy.
91 TEST_F(ChromeSelectFilePolicyTest, MAYBE_ExpectAsynchronousListenerCall) { 91 TEST_F(ChromeSelectFilePolicyTest, MAYBE_ExpectAsynchronousListenerCall) {
92 MessageLoopForUI message_loop; 92 MessageLoopForUI message_loop;
93 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); 93 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
94 94
95 ScopedTestingLocalState local_state( 95 ScopedTestingLocalState local_state(
96 static_cast<TestingBrowserProcess*>(g_browser_process)); 96 static_cast<TestingBrowserProcess*>(g_browser_process));
97 97
98 scoped_ptr<FileSelectionUser> file_selection_user(new FileSelectionUser()); 98 scoped_ptr<FileSelectionUser> file_selection_user(new FileSelectionUser());
99 99
100 // Disallow file-selection dialogs. 100 // Disallow file-selection dialogs.
101 local_state.Get()->SetManagedPref( 101 local_state.Get()->SetManagedPref(
102 prefs::kAllowFileSelectionDialogs, 102 prefs::kAllowFileSelectionDialogs,
103 Value::CreateBooleanValue(false)); 103 Value::CreateBooleanValue(false));
104 104
105 file_selection_user->StartFileSelection(); 105 file_selection_user->StartFileSelection();
106 } 106 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/certificate_dialogs.cc ('k') | chrome/browser/ui/select_file_dialog.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698