This source file includes following definitions.
- TEST
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/shell_dialogs/select_file_dialog.h"
#include "ui/shell_dialogs/select_file_dialog_win.h"
TEST(ShellDialogsWin, AppendExtensionIfNeeded) {
struct AppendExtensionTestCase {
const wchar_t* filename;
const wchar_t* filter_selected;
const wchar_t* suggested_ext;
const wchar_t* expected_filename;
} test_cases[] = {
{ L"sample.html", L"*.txt", L"txt", L"sample.html" },
{ L"sample.reg", L"*.txt", L"txt", L"sample.reg" },
{ L"sample.unknown", L"*.txt", L"txt", L"sample.unknown.txt" },
{ L"sample", L"*.txt", L"txt", L"sample.txt" },
{ L"sample.unknown", L"*.unknown", L"unknown", L"sample.unknown" },
{ L"txt", L"*.txt", L"txt", L"txt.txt" },
{ L"sample.txt.", L"*.txt", L"txt", L"sample.txt.txt" },
{ L"...", L"*.txt", L"txt", L"...txt" },
{ L"sample.unknown", L"*.*", L"", L"sample.unknown" },
};
for (size_t i = 0; i < arraysize(test_cases); ++i) {
EXPECT_EQ(std::wstring(test_cases[i].expected_filename),
ui::AppendExtensionIfNeeded(test_cases[i].filename,
test_cases[i].filter_selected,
test_cases[i].suggested_ext));
}
}