From 9ccbb370aa45f477941e0599d4ce7c89fac64101 Mon Sep 17 00:00:00 2001 From: "jcampan@chromium.org" Date: Fri, 10 Oct 2008 18:50:32 +0000 Subject: This CL adds prompting for dangerous types of files (executable) when they are automatically downloaded. The file is saved with a temporary name (dangerous_download_xxxx.download) in the download directory and the user is presented (in the download shelf and the download tab if opened) with a warning message and buttons to save/discard the download. If discarded the download is removed (and its file deleted). If saved, download goes as usual. Dangerous downloads not confirmed by the user are deleted on shutdown. TEST=Download a small exe file, try using the save/discard button from the download shelf and from the download tab (the intent is that the file has been entirely downloaded by the time you take action). Try again with a slow/big download (that time the download is expected not to be finished when approved/discarded). Review URL: http://codereview.chromium.org/6043 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3228 0039d316-1c4b-4281-b951-d872f2087c98 --- base/string_util_unittest.cc | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'base/string_util_unittest.cc') diff --git a/base/string_util_unittest.cc b/base/string_util_unittest.cc index e438ebb..25f43c6 100644 --- a/base/string_util_unittest.cc +++ b/base/string_util_unittest.cc @@ -1380,3 +1380,29 @@ TEST(StringUtilTest, WprintfFormatPortabilityTest) { } } +TEST(StringUtilTest, ElideString) { + struct TestData { + const wchar_t* input; + int max_len; + bool result; + const wchar_t* output; + } cases[] = { + { L"Hello", 0, true, L"" }, + { L"", 0, false, L"" }, + { L"Hello, my name is Tom", 1, true, L"H" }, + { L"Hello, my name is Tom", 2, true, L"He" }, + { L"Hello, my name is Tom", 3, true, L"H.m" }, + { L"Hello, my name is Tom", 4, true, L"H..m" }, + { L"Hello, my name is Tom", 5, true, L"H...m" }, + { L"Hello, my name is Tom", 6, true, L"He...m" }, + { L"Hello, my name is Tom", 7, true, L"He...om" }, + { L"Hello, my name is Tom", 10, true, L"Hell...Tom" }, + { L"Hello, my name is Tom", 100, false, L"Hello, my name is Tom" } + }; + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { + std::wstring output; + EXPECT_EQ(cases[i].result, + ElideString(cases[i].input, cases[i].max_len, &output)); + EXPECT_TRUE(output == cases[i].output); + } +} -- cgit v1.1