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

Side by Side Diff: chrome/browser/browsing_data_helper_unittest.cc

Issue 9958111: Adding a BrowsingDataHelper class to hold some useful methods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase onto trunk. Created 8 years, 8 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/browsing_data_helper.cc ('k') | chrome/browser/browsing_data_remover.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 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/browsing_data_helper.h"
6
7 #include "base/stringprintf.h"
8 #include "chrome/common/url_constants.h"
9 #include "content/public/common/url_constants.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "googleurl/src/gurl.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
13
14 namespace {
15
16 class BrowsingDataHelperTest : public testing::Test {
17 public:
18 BrowsingDataHelperTest() {}
19 virtual ~BrowsingDataHelperTest() {}
20
21 bool IsValidScheme(const std::string& scheme) {
22 GURL test(scheme + "://example.com");
23 return (BrowsingDataHelper::HasValidScheme(test) &&
24 BrowsingDataHelper::IsValidScheme(scheme) &&
25 BrowsingDataHelper::IsValidScheme(
26 WebKit::WebString::fromUTF8(scheme)));
27 }
28
29 private:
30 DISALLOW_COPY_AND_ASSIGN(BrowsingDataHelperTest);
31 };
32
33 TEST_F(BrowsingDataHelperTest, WebSafeSchemesAreValid) {
34 EXPECT_TRUE(IsValidScheme(chrome::kHttpScheme));
35 EXPECT_TRUE(IsValidScheme(chrome::kHttpsScheme));
36 EXPECT_TRUE(IsValidScheme(chrome::kFtpScheme));
37 EXPECT_TRUE(IsValidScheme(chrome::kDataScheme));
38 EXPECT_TRUE(IsValidScheme("feed"));
39 EXPECT_TRUE(IsValidScheme(chrome::kBlobScheme));
40 EXPECT_TRUE(IsValidScheme(chrome::kFileSystemScheme));
41
42 EXPECT_FALSE(IsValidScheme("invalid-scheme-i-just-made-up"));
43 }
44
45 TEST_F(BrowsingDataHelperTest, ChromeSchemesAreInvalid) {
46 EXPECT_FALSE(IsValidScheme(chrome::kExtensionScheme));
47 EXPECT_FALSE(IsValidScheme(chrome::kAboutScheme));
48 EXPECT_FALSE(IsValidScheme(chrome::kChromeDevToolsScheme));
49 EXPECT_FALSE(IsValidScheme(chrome::kChromeInternalScheme));
50 EXPECT_FALSE(IsValidScheme(chrome::kChromeUIScheme));
51 EXPECT_FALSE(IsValidScheme(chrome::kJavaScriptScheme));
52 EXPECT_FALSE(IsValidScheme(chrome::kMailToScheme));
53 EXPECT_FALSE(IsValidScheme(chrome::kMetadataScheme));
54 EXPECT_FALSE(IsValidScheme(chrome::kSwappedOutScheme));
55 EXPECT_FALSE(IsValidScheme(chrome::kViewSourceScheme));
56 }
57
58 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data_helper.cc ('k') | chrome/browser/browsing_data_remover.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698