OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/shell_dialogs.h" |
| 6 #include "testing/gtest/include/gtest/gtest.h" |
| 7 |
| 8 TEST(AppendExtensionIfNeeded, EndingInPeriod_ExtensionAppended) { |
| 9 const std::wstring filename = L"sample.txt."; |
| 10 const std::wstring filter_selected = L"*.txt"; |
| 11 const std::wstring suggested_ext = L"txt"; |
| 12 |
| 13 const std::wstring actual_filename = AppendExtensionIfNeeded(filename, |
| 14 filter_selected, suggested_ext); |
| 15 |
| 16 ASSERT_EQ(L"sample.txt.txt", actual_filename); |
| 17 } |
| 18 |
| 19 TEST(AppendExtensionIfNeeded, UnknownMimeType_ExtensionAppended) { |
| 20 const std::wstring filename = L"sample.unknown-mime-type"; |
| 21 const std::wstring filter_selected = L"*.txt"; |
| 22 const std::wstring suggested_ext = L"txt"; |
| 23 |
| 24 const std::wstring actual_filename = AppendExtensionIfNeeded(filename, |
| 25 filter_selected, suggested_ext); |
| 26 |
| 27 ASSERT_EQ(L"sample.unknown-mime-type.txt", actual_filename); |
| 28 } |
| 29 |
| 30 TEST(AppendExtensionIfNeeded, RecognizableMimeType_NoExtensionAppended) { |
| 31 const std::wstring filename = L"sample.html"; |
| 32 const std::wstring filter_selected = L"*.txt"; |
| 33 const std::wstring suggested_ext = L"txt"; |
| 34 |
| 35 const std::wstring actual_filename = AppendExtensionIfNeeded(filename, |
| 36 filter_selected, suggested_ext); |
| 37 |
| 38 ASSERT_EQ(L"sample.html", actual_filename); |
| 39 } |
| 40 |
| 41 TEST(AppendExtensionIfNeeded, OnlyPeriods_ExtensionAppended) { |
| 42 const std::wstring filename = L"..."; |
| 43 const std::wstring filter_selected = L"*.txt"; |
| 44 const std::wstring suggested_ext = L"txt"; |
| 45 |
| 46 const std::wstring actual_filename = AppendExtensionIfNeeded(filename, |
| 47 filter_selected, suggested_ext); |
| 48 |
| 49 ASSERT_EQ(L"...txt", actual_filename); |
| 50 } |
| 51 |
| 52 TEST(AppendExtensionIfNeeded, EqualToExtension_ExtensionAppended) { |
| 53 const std::wstring filename = L"txt"; |
| 54 const std::wstring filter_selected = L"*.txt"; |
| 55 const std::wstring suggested_ext = L"txt"; |
| 56 |
| 57 const std::wstring actual_filename = AppendExtensionIfNeeded(filename, |
| 58 filter_selected, suggested_ext); |
| 59 |
| 60 ASSERT_EQ(L"txt.txt", actual_filename); |
| 61 } |
| 62 |
| 63 TEST(AppendExtensionIfNeeded, AllFilesFilter_NoExtensionAppended) { |
| 64 const std::wstring filename = L"sample.unknown-mime-type"; |
| 65 const std::wstring filter_selected = L"*.*"; |
| 66 const std::wstring suggested_ext; |
| 67 |
| 68 const std::wstring actual_filename = AppendExtensionIfNeeded(filename, |
| 69 filter_selected, suggested_ext); |
| 70 |
| 71 ASSERT_EQ(L"sample.unknown-mime-type", actual_filename); |
| 72 } |
OLD | NEW |