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

Unified Diff: chrome/browser/chrome_select_file_policy_unittest.cc

Issue 10667026: Start consolidating cross-port file selection code into ui/base/dialogs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chrome_select_file_policy_unittest.cc
diff --git a/chrome/browser/ui/select_file_dialog_unittest.cc b/chrome/browser/chrome_select_file_policy_unittest.cc
similarity index 77%
rename from chrome/browser/ui/select_file_dialog_unittest.cc
rename to chrome/browser/chrome_select_file_policy_unittest.cc
index 07bca44bccbf0c6d01c020b8594a3c17df8ac131..c55df28d5357b244590ef912d356f7e7c1e6b643 100644
--- a/chrome/browser/ui/select_file_dialog_unittest.cc
+++ b/chrome/browser/chrome_select_file_policy_unittest.cc
@@ -2,12 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/bind.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/message_loop.h"
#include "base/string16.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chrome_select_file_policy.h"
sky 2012/06/26 00:07:18 test include order should match that of .cc includ
#include "chrome/browser/prefs/browser_prefs.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/ui/browser.h"
@@ -27,6 +29,12 @@
using content::BrowserThread;
+namespace {
+
+void SetToTrue(bool* var) {
+ *var = true;
+}
+
class FileSelectionUser : public SelectFileDialog::Listener {
public:
FileSelectionUser()
@@ -38,7 +46,7 @@ class FileSelectionUser : public SelectFileDialog::Listener {
select_file_dialog_->ListenerDestroyed();
}
- void StartFileSelection() {
+ void StartFileSelection(bool* blocked) {
CHECK(!select_file_dialog_.get());
select_file_dialog_ = SelectFileDialog::Create(this);
@@ -46,15 +54,16 @@ class FileSelectionUser : public SelectFileDialog::Listener {
const string16 title=string16();
file_selection_initialisation_in_progress = true;
- select_file_dialog_->SelectFile(SelectFileDialog::SELECT_OPEN_FILE,
- title,
- file_path,
- NULL,
- 0,
- FILE_PATH_LITERAL(""),
- NULL,
- NULL,
- NULL);
+ select_file_dialog_->SelectFile(
+ SelectFileDialog::SELECT_OPEN_FILE,
+ title,
+ file_path,
+ NULL,
+ 0,
+ FILE_PATH_LITERAL(""),
+ base::Bind(&SetToTrue, base::Unretained(blocked)),
+ NULL,
+ NULL);
file_selection_initialisation_in_progress = false;
}
@@ -78,23 +87,30 @@ class FileSelectionUser : public SelectFileDialog::Listener {
bool file_selection_initialisation_in_progress;
};
-typedef testing::Test FileSelectionDialogTest;
+} // namespace
+
+typedef testing::Test ChromeSelectFilePolicyTest;
// Tests if SelectFileDialog::SelectFile returns asynchronously with
// file-selection dialogs disabled by policy.
-TEST_F(FileSelectionDialogTest, MAYBE_ExpectAsynchronousListenerCall) {
+TEST_F(ChromeSelectFilePolicyTest, MAYBE_ExpectAsynchronousListenerCall) {
MessageLoopForUI message_loop;
content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
+ // We should check chrome policy before spawning a dialog.
+ SelectFileDialog::SetFilePolicy(new ChromeSelectFilePolicy);
+
ScopedTestingLocalState local_state(
static_cast<TestingBrowserProcess*>(g_browser_process));
- scoped_ptr<FileSelectionUser> file_selection_user(new FileSelectionUser());
+ scoped_ptr<FileSelectionUser> file_selection_user(new FileSelectionUser);
// Disallow file-selection dialogs.
local_state.Get()->SetManagedPref(
prefs::kAllowFileSelectionDialogs,
Value::CreateBooleanValue(false));
- file_selection_user->StartFileSelection();
+ bool blocked = false;
+ file_selection_user->StartFileSelection(&blocked);
+ EXPECT_TRUE(blocked);
}

Powered by Google App Engine
This is Rietveld 408576698