| OLD | NEW |
| 1 // Copyright (c) 2011 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/select_file_dialog.h" | 5 #include "ui/base/dialogs/select_file_dialog.h" |
| 6 #include "ui/base/dialogs/select_file_dialog_win.h" |
| 6 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 7 | 8 |
| 8 TEST(ShellDialogsWin, AppendExtensionIfNeeded) { | 9 TEST(ShellDialogsWin, AppendExtensionIfNeeded) { |
| 9 struct AppendExtensionTestCase { | 10 struct AppendExtensionTestCase { |
| 10 wchar_t* filename; | 11 wchar_t* filename; |
| 11 wchar_t* filter_selected; | 12 wchar_t* filter_selected; |
| 12 wchar_t* suggested_ext; | 13 wchar_t* suggested_ext; |
| 13 wchar_t* expected_filename; | 14 wchar_t* expected_filename; |
| 14 } test_cases[] = { | 15 } test_cases[] = { |
| 15 // Known extensions, with or without associated MIME types, should not get | 16 // Known extensions, with or without associated MIME types, should not get |
| (...skipping 14 matching lines...) Expand all Loading... |
| 30 // Trailing dots should cause us to append an extension. | 31 // Trailing dots should cause us to append an extension. |
| 31 { L"sample.txt.", L"*.txt", L"txt", L"sample.txt.txt" }, | 32 { L"sample.txt.", L"*.txt", L"txt", L"sample.txt.txt" }, |
| 32 { L"...", L"*.txt", L"txt", L"...txt" }, | 33 { L"...", L"*.txt", L"txt", L"...txt" }, |
| 33 | 34 |
| 34 // If the filter is changed to "All files", we allow any filename. | 35 // If the filter is changed to "All files", we allow any filename. |
| 35 { L"sample.unknown", L"*.*", L"", L"sample.unknown" }, | 36 { L"sample.unknown", L"*.*", L"", L"sample.unknown" }, |
| 36 }; | 37 }; |
| 37 | 38 |
| 38 for (size_t i = 0; i < arraysize(test_cases); ++i) { | 39 for (size_t i = 0; i < arraysize(test_cases); ++i) { |
| 39 EXPECT_EQ(std::wstring(test_cases[i].expected_filename), | 40 EXPECT_EQ(std::wstring(test_cases[i].expected_filename), |
| 40 AppendExtensionIfNeeded(test_cases[i].filename, | 41 ui::AppendExtensionIfNeeded(test_cases[i].filename, |
| 41 test_cases[i].filter_selected, | 42 test_cases[i].filter_selected, |
| 42 test_cases[i].suggested_ext)); | 43 test_cases[i].suggested_ext)); |
| 43 } | 44 } |
| 44 } | 45 } |
| OLD | NEW |