Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Unified Diff: chrome/browser/views/shell_dialogs_win_unittest.cc

Issue 2893001: Clean up and simplify how we deal with filename extensions on Windows. Allow... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/views/shell_dialogs_win.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/views/shell_dialogs_win_unittest.cc
===================================================================
--- chrome/browser/views/shell_dialogs_win_unittest.cc (revision 0)
+++ chrome/browser/views/shell_dialogs_win_unittest.cc (revision 0)
@@ -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);
+}
Property changes on: chrome/browser/views/shell_dialogs_win_unittest.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « chrome/browser/views/shell_dialogs_win.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698