- Add open folder dialog support (FILE_DIALOG_OPEN_FOLDER mode) for CefBrowserHost::RunFileDialog (issue #1030).

- Standardize file dialog behavior across all platforms (issue #1492).
-- Show a file type filter list on OS X.
-- Show the file extensions as part of the filter list description on all platforms (e.g. "Image Types (*.png;*.gif;*.jpg)").
-- Rename the CefBrowserHost::RunFileDialog |accept_types| argument to |accept_filters| and expand support for filters that will be displayed as-is in addition to the currently supported mime-type and extension-based filters. For example, a filter value of "Supported Image Types|.png;.gif;.jpg" will display "Supported Image Types (*.png;*.gif;*.jpg)" in the filter drop-down list and accept *.png, *.gif and *.jpg files.
-- Persist the selected filter item index by passing a new |selected_accept_filter| argument to CefBrowserHost::RunFileDialog and returning the newly selected index via the CefRunFileDialogCallback and CefFileDialogCallback callbacks.
-- Rename the CefBrowserHost::RunFileDialog |default_file_name| argument to |default_file_path| and use the directory component, if any, to set the default directory location. If |default_file_path| ends in a trailing path separator it will be treated as a directory without a file name component.
-- Add FILE_DIALOG_OVERWRITEPROMPT_FLAG and FILE_DIALOG_HIDEREADONLY_FLAG values to cef_file_dialog_mode_t for controlling those behaviors where possible.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1973 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2015-01-20 18:24:54 +00:00
parent 3eabbb2e7d
commit e50ea8c29f
29 changed files with 1113 additions and 436 deletions

View File

@@ -22,6 +22,7 @@ class DialogTestHandler : public TestHandler {
: mode(dialog_mode),
title("Test Title"),
default_file_name("Test File Name"),
selected_accept_filter(1), // Something other than 0 for testing.
callback_async(false),
callback_cancel(false) {
accept_types.push_back("text/*");
@@ -33,6 +34,7 @@ class DialogTestHandler : public TestHandler {
CefString title;
CefString default_file_name;
std::vector<CefString> accept_types;
int selected_accept_filter;
bool callback_async; // True if the callback should execute asynchronously.
bool callback_cancel; // True if the callback should cancel.
@@ -46,17 +48,18 @@ class DialogTestHandler : public TestHandler {
}
void OnFileDialogDismissed(
CefRefPtr<CefBrowserHost> browser_host,
int selected_accept_filter,
const std::vector<CefString>& file_paths) override {
handler_->got_onfiledialogdismissed_.yes();
std::string url = browser_host->GetBrowser()->GetMainFrame()->GetURL();
EXPECT_STREQ(kTestUrl, url.c_str());
if (handler_->config_.callback_cancel)
if (handler_->config_.callback_cancel) {
EXPECT_EQ(0, selected_accept_filter);
EXPECT_TRUE(file_paths.empty());
else
} else {
EXPECT_EQ(handler_->config_.selected_accept_filter,
selected_accept_filter);
TestStringVectorEqual(handler_->config_.callback_paths, file_paths);
}
handler_->DestroyTest();
handler_ = NULL;
@@ -89,6 +92,7 @@ class DialogTestHandler : public TestHandler {
config_.title,
config_.default_file_name,
config_.accept_types,
config_.selected_accept_filter,
new Callback(this));
}
@@ -96,7 +100,8 @@ class DialogTestHandler : public TestHandler {
if (config_.callback_cancel)
callback->Cancel();
else
callback->Continue(config_.callback_paths);
callback->Continue(config_.selected_accept_filter,
config_.callback_paths);
}
// CefDialogHandler
@@ -106,6 +111,7 @@ class DialogTestHandler : public TestHandler {
const CefString& title,
const CefString& default_file_name,
const std::vector<CefString>& accept_types,
int selected_accept_filter,
CefRefPtr<CefFileDialogCallback> callback) override {
got_onfiledialog_.yes();
@@ -157,6 +163,22 @@ TEST(DialogTest, FileEmptyParams) {
ReleaseAndWaitForDestructor(handler);
}
TEST(DialogTest, FileAdditionalFlags) {
DialogTestHandler::TestConfig config(
static_cast<cef_file_dialog_mode_t>(FILE_DIALOG_OPEN |
FILE_DIALOG_HIDEREADONLY_FLAG |
FILE_DIALOG_OVERWRITEPROMPT_FLAG));
config.title.clear();
config.default_file_name.clear();
config.accept_types.clear();
config.callback_async = false;
config.callback_cancel = false;
CefRefPtr<DialogTestHandler> handler = new DialogTestHandler(config);
handler->ExecuteTest();
ReleaseAndWaitForDestructor(handler);
}
TEST(DialogTest, FileOpen) {
DialogTestHandler::TestConfig config(FILE_DIALOG_OPEN);
config.callback_async = false;
@@ -243,6 +265,48 @@ TEST(DialogTest, FileOpenMultipleAsyncCancel) {
ReleaseAndWaitForDestructor(handler);
}
TEST(DialogTest, FileOpenFolder) {
DialogTestHandler::TestConfig config(FILE_DIALOG_OPEN_FOLDER);
config.callback_async = false;
config.callback_cancel = false;
config.callback_paths.push_back("/path/to/folder");
CefRefPtr<DialogTestHandler> handler = new DialogTestHandler(config);
handler->ExecuteTest();
ReleaseAndWaitForDestructor(handler);
}
TEST(DialogTest, FileOpenFolderCancel) {
DialogTestHandler::TestConfig config(FILE_DIALOG_OPEN_FOLDER);
config.callback_async = false;
config.callback_cancel = true;
CefRefPtr<DialogTestHandler> handler = new DialogTestHandler(config);
handler->ExecuteTest();
ReleaseAndWaitForDestructor(handler);
}
TEST(DialogTest, FileOpenFolderAsync) {
DialogTestHandler::TestConfig config(FILE_DIALOG_OPEN_FOLDER);
config.callback_async = true;
config.callback_cancel = false;
config.callback_paths.push_back("/path/to/folder");
CefRefPtr<DialogTestHandler> handler = new DialogTestHandler(config);
handler->ExecuteTest();
ReleaseAndWaitForDestructor(handler);
}
TEST(DialogTest, FileOpenFolderAsyncCancel) {
DialogTestHandler::TestConfig config(FILE_DIALOG_OPEN_FOLDER);
config.callback_async = false;
config.callback_cancel = true;
CefRefPtr<DialogTestHandler> handler = new DialogTestHandler(config);
handler->ExecuteTest();
ReleaseAndWaitForDestructor(handler);
}
TEST(DialogTest, FileSave) {
DialogTestHandler::TestConfig config(FILE_DIALOG_SAVE);
config.callback_async = false;