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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/views/shell_dialogs_win.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(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 }
OLDNEW
« 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