diff options
Diffstat (limited to 'chrome/browser/views/shell_dialogs_win_unittest.cc')
-rw-r--r-- | chrome/browser/views/shell_dialogs_win_unittest.cc | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/chrome/browser/views/shell_dialogs_win_unittest.cc b/chrome/browser/views/shell_dialogs_win_unittest.cc new file mode 100644 index 0000000..b267e16 --- /dev/null +++ b/chrome/browser/views/shell_dialogs_win_unittest.cc @@ -0,0 +1,72 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/shell_dialogs.h" +#include "testing/gtest/include/gtest/gtest.h" + +TEST(AppendExtensionIfNeeded, EndingInPeriod_ExtensionAppended) { + const std::wstring filename = L"sample.txt."; + const std::wstring filter_selected = L"*.txt"; + const std::wstring suggested_ext = L"txt"; + + const std::wstring actual_filename = AppendExtensionIfNeeded(filename, + filter_selected, suggested_ext); + + ASSERT_EQ(L"sample.txt.txt", actual_filename); +} + +TEST(AppendExtensionIfNeeded, UnknownMimeType_ExtensionAppended) { + const std::wstring filename = L"sample.unknown-mime-type"; + const std::wstring filter_selected = L"*.txt"; + const std::wstring suggested_ext = L"txt"; + + const std::wstring actual_filename = AppendExtensionIfNeeded(filename, + filter_selected, suggested_ext); + + ASSERT_EQ(L"sample.unknown-mime-type.txt", actual_filename); +} + +TEST(AppendExtensionIfNeeded, RecognizableMimeType_NoExtensionAppended) { + const std::wstring filename = L"sample.html"; + const std::wstring filter_selected = L"*.txt"; + const std::wstring suggested_ext = L"txt"; + + const std::wstring actual_filename = AppendExtensionIfNeeded(filename, + filter_selected, suggested_ext); + + ASSERT_EQ(L"sample.html", actual_filename); +} + +TEST(AppendExtensionIfNeeded, OnlyPeriods_ExtensionAppended) { + const std::wstring filename = L"..."; + const std::wstring filter_selected = L"*.txt"; + const std::wstring suggested_ext = L"txt"; + + const std::wstring actual_filename = AppendExtensionIfNeeded(filename, + filter_selected, suggested_ext); + + ASSERT_EQ(L"...txt", actual_filename); +} + +TEST(AppendExtensionIfNeeded, EqualToExtension_ExtensionAppended) { + const std::wstring filename = L"txt"; + const std::wstring filter_selected = L"*.txt"; + const std::wstring suggested_ext = L"txt"; + + const std::wstring actual_filename = AppendExtensionIfNeeded(filename, + filter_selected, suggested_ext); + + ASSERT_EQ(L"txt.txt", actual_filename); +} + +TEST(AppendExtensionIfNeeded, AllFilesFilter_NoExtensionAppended) { + const std::wstring filename = L"sample.unknown-mime-type"; + const std::wstring filter_selected = L"*.*"; + const std::wstring suggested_ext; + + const std::wstring actual_filename = AppendExtensionIfNeeded(filename, + filter_selected, suggested_ext); + + ASSERT_EQ(L"sample.unknown-mime-type", actual_filename); +} |