| 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 "chrome/browser/ui/select_file_dialog.h" | 5 #include "chrome/browser/ui/select_file_dialog.h" |
| 6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
| 7 | 7 |
| 8 // This function is declared extern such that it is accessible for unit tests |
| 9 // in /chrome/browser/ui/views/select_file_dialog_win_unittest.cc |
| 10 extern std::wstring AppendExtensionIfNeeded(const std::wstring& filename, |
| 11 const std::wstring& filter_selected, |
| 12 const std::wstring& suggested_ext); |
| 13 |
| 8 TEST(ShellDialogsWin, AppendExtensionIfNeeded) { | 14 TEST(ShellDialogsWin, AppendExtensionIfNeeded) { |
| 9 struct AppendExtensionTestCase { | 15 struct AppendExtensionTestCase { |
| 10 wchar_t* filename; | 16 wchar_t* filename; |
| 11 wchar_t* filter_selected; | 17 wchar_t* filter_selected; |
| 12 wchar_t* suggested_ext; | 18 wchar_t* suggested_ext; |
| 13 wchar_t* expected_filename; | 19 wchar_t* expected_filename; |
| 14 } test_cases[] = { | 20 } test_cases[] = { |
| 15 // Known extensions, with or without associated MIME types, should not get | 21 // Known extensions, with or without associated MIME types, should not get |
| 16 // an extension appended. | 22 // an extension appended. |
| 17 { L"sample.html", L"*.txt", L"txt", L"sample.html" }, | 23 { L"sample.html", L"*.txt", L"txt", L"sample.html" }, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 35 { L"sample.unknown", L"*.*", L"", L"sample.unknown" }, | 41 { L"sample.unknown", L"*.*", L"", L"sample.unknown" }, |
| 36 }; | 42 }; |
| 37 | 43 |
| 38 for (size_t i = 0; i < arraysize(test_cases); ++i) { | 44 for (size_t i = 0; i < arraysize(test_cases); ++i) { |
| 39 EXPECT_EQ(std::wstring(test_cases[i].expected_filename), | 45 EXPECT_EQ(std::wstring(test_cases[i].expected_filename), |
| 40 AppendExtensionIfNeeded(test_cases[i].filename, | 46 AppendExtensionIfNeeded(test_cases[i].filename, |
| 41 test_cases[i].filter_selected, | 47 test_cases[i].filter_selected, |
| 42 test_cases[i].suggested_ext)); | 48 test_cases[i].suggested_ext)); |
| 43 } | 49 } |
| 44 } | 50 } |
| OLD | NEW |