OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/file_path.h" | 5 #include "base/file_path.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/string16.h" | 7 #include "base/string16.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
10 #include "chrome/browser/prefs/browser_prefs.h" | 11 #include "chrome/browser/prefs/browser_prefs.h" |
11 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/shell_dialogs.h" | 13 #include "chrome/browser/ui/shell_dialogs.h" |
13 #include "chrome/test/base/testing_browser_process_test.h" | 14 #include "chrome/test/base/testing_browser_process.h" |
14 #include "chrome/test/base/testing_pref_service.h" | 15 #include "chrome/test/base/testing_pref_service.h" |
15 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
17 | 18 |
18 class FileSelectionUser : public SelectFileDialog::Listener { | 19 class FileSelectionUser : public SelectFileDialog::Listener { |
19 public: | 20 public: |
20 FileSelectionUser() | 21 FileSelectionUser() |
21 : file_selection_initialisation_in_progress(false) { | 22 : file_selection_initialisation_in_progress(false) { |
22 } | 23 } |
23 | 24 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 virtual void FileSelectionCanceled(void* params) { | 60 virtual void FileSelectionCanceled(void* params) { |
60 ASSERT_FALSE(file_selection_initialisation_in_progress); | 61 ASSERT_FALSE(file_selection_initialisation_in_progress); |
61 } | 62 } |
62 | 63 |
63 private: | 64 private: |
64 scoped_refptr<SelectFileDialog> select_file_dialog_; | 65 scoped_refptr<SelectFileDialog> select_file_dialog_; |
65 | 66 |
66 bool file_selection_initialisation_in_progress; | 67 bool file_selection_initialisation_in_progress; |
67 }; | 68 }; |
68 | 69 |
69 typedef TestingBrowserProcessTest FileSelectionDialogTest; | 70 typedef testing::Test FileSelectionDialogTest; |
70 | 71 |
71 // Tests if SelectFileDialog::SelectFile returns asynchronously with | 72 // Tests if SelectFileDialog::SelectFile returns asynchronously with |
72 // file-selection dialogs disabled by policy. | 73 // file-selection dialogs disabled by policy. |
73 TEST_F(FileSelectionDialogTest, ExpectAsynchronousListenerCall) { | 74 TEST_F(FileSelectionDialogTest, ExpectAsynchronousListenerCall) { |
74 MessageLoopForUI message_loop; | 75 MessageLoopForUI message_loop; |
75 BrowserThread ui_thread(BrowserThread::UI, &message_loop); | 76 BrowserThread ui_thread(BrowserThread::UI, &message_loop); |
76 | 77 |
77 ScopedTestingLocalState local_state_(testing_browser_process_.get()); | 78 ScopedTestingLocalState local_state( |
| 79 static_cast<TestingBrowserProcess*>(g_browser_process)); |
78 | 80 |
79 scoped_ptr<FileSelectionUser> file_selection_user(new FileSelectionUser()); | 81 scoped_ptr<FileSelectionUser> file_selection_user(new FileSelectionUser()); |
80 | 82 |
81 // Disallow file-selection dialogs. | 83 // Disallow file-selection dialogs. |
82 local_state_.Get()->SetManagedPref( | 84 local_state.Get()->SetManagedPref( |
83 prefs::kAllowFileSelectionDialogs, | 85 prefs::kAllowFileSelectionDialogs, |
84 Value::CreateBooleanValue(false)); | 86 Value::CreateBooleanValue(false)); |
85 | 87 |
86 file_selection_user->StartFileSelection(); | 88 file_selection_user->StartFileSelection(); |
87 } | 89 } |
OLD | NEW |