OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/shell_dialogs.h" | 5 #include "chrome/browser/shell_dialogs.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 | 7 |
8 TEST(AppendExtensionIfNeeded, EndingInPeriod_ExtensionAppended) { | 8 TEST(AppendExtensionIfNeeded, EndingInPeriod_ExtensionAppended) { |
9 const std::wstring filename = L"sample.txt."; | 9 const std::wstring filename = L"sample.txt."; |
10 const std::wstring filter_selected = L"*.txt"; | 10 const std::wstring filter_selected = L"*.txt"; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 TEST(AppendExtensionIfNeeded, AllFilesFilter_NoExtensionAppended) { | 63 TEST(AppendExtensionIfNeeded, AllFilesFilter_NoExtensionAppended) { |
64 const std::wstring filename = L"sample.unknown-mime-type"; | 64 const std::wstring filename = L"sample.unknown-mime-type"; |
65 const std::wstring filter_selected = L"*.*"; | 65 const std::wstring filter_selected = L"*.*"; |
66 const std::wstring suggested_ext; | 66 const std::wstring suggested_ext; |
67 | 67 |
68 const std::wstring actual_filename = AppendExtensionIfNeeded(filename, | 68 const std::wstring actual_filename = AppendExtensionIfNeeded(filename, |
69 filter_selected, suggested_ext); | 69 filter_selected, suggested_ext); |
70 | 70 |
71 ASSERT_EQ(L"sample.unknown-mime-type", actual_filename); | 71 ASSERT_EQ(L"sample.unknown-mime-type", actual_filename); |
72 } | 72 } |
| 73 |
| 74 TEST(AppendExtensionIfNeeded, StripsDotsForUnknownSelectedMimeType) { |
| 75 const std::wstring filename = L"product"; |
| 76 const std::wstring filter_selected = L"*.unknown-extension."; |
| 77 const std::wstring suggested_ext = L"html"; |
| 78 |
| 79 const std::wstring actual_filename = AppendExtensionIfNeeded(filename, |
| 80 filter_selected, suggested_ext); |
| 81 |
| 82 ASSERT_EQ(L"product.html", actual_filename); |
| 83 } |
| 84 |
| 85 TEST(AppendExtensionIfNeeded, EqualToExtension_NoDoubleExtension) { |
| 86 // Make sure we don't add a duplicate extension like .tbl.tbl for |
| 87 // files that the system doesn't have a mime type for. |
| 88 const std::wstring filename = L"product.tbl"; |
| 89 const std::wstring filter_selected = L"*.tbl"; |
| 90 const std::wstring suggested_ext = L"tbl"; |
| 91 |
| 92 const std::wstring actual_filename = AppendExtensionIfNeeded(filename, |
| 93 filter_selected, suggested_ext); |
| 94 |
| 95 ASSERT_EQ(L"product.tbl", actual_filename); |
| 96 } |
OLD | NEW |