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

Side by Side Diff: components/dom_distiller/core/url_utils_unittest.cc

Issue 442503002: Retrieve article original URL from entryID (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: string reference Created 6 years, 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/dom_distiller/core/url_utils.h" 5 #include "components/dom_distiller/core/url_utils.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace dom_distiller { 9 namespace dom_distiller {
10 10
11 namespace url_utils { 11 namespace url_utils {
12 12
13 TEST(DomDistillerUrlUtilsTest, TestPathUtil) { 13 TEST(DomDistillerUrlUtilsTest, TestPathUtil) {
14 const std::string single_key = "mypath?foo=bar"; 14 const std::string single_key = "mypath?foo=bar";
15 EXPECT_EQ("bar", GetValueForKeyInUrlPathQuery(single_key, "foo")); 15 EXPECT_EQ("bar", GetValueForKeyInUrlPathQuery(single_key, "foo"));
16 const std::string two_keys = "mypath?key1=foo&key2=bar"; 16 const std::string two_keys = "mypath?key1=foo&key2=bar";
17 EXPECT_EQ("foo", GetValueForKeyInUrlPathQuery(two_keys, "key1")); 17 EXPECT_EQ("foo", GetValueForKeyInUrlPathQuery(two_keys, "key1"));
18 EXPECT_EQ("bar", GetValueForKeyInUrlPathQuery(two_keys, "key2")); 18 EXPECT_EQ("bar", GetValueForKeyInUrlPathQuery(two_keys, "key2"));
19 const std::string multiple_same_key = "mypath?key=foo&key=bar"; 19 const std::string multiple_same_key = "mypath?key=foo&key=bar";
20 EXPECT_EQ("foo", GetValueForKeyInUrlPathQuery(multiple_same_key, "key")); 20 EXPECT_EQ("foo", GetValueForKeyInUrlPathQuery(multiple_same_key, "key"));
21 } 21 }
22 22
23 TEST(DomDistillerUrlUtilsTest, TestGetValueForKeyInUrlPathQuery) {
24 // Tests an invalid url.
25 const std::string invalid_url = "http://%40[::1]/";
26 EXPECT_EQ("", GetValueForKeyInUrlPathQuery(invalid_url, "key"));
27
28 // Test a valid URL with the key we are searching for.
29 const std::string valid_url_with_key = "http://www.google.com?key=foo";
30 EXPECT_EQ("foo", GetValueForKeyInUrlPathQuery(valid_url_with_key, "key"));
31
32 // Test a valid URL without the key we are searching for.
33 const std::string valid_url_no_key = "http://www.google.com";
34 EXPECT_EQ("", GetValueForKeyInUrlPathQuery(valid_url_no_key, "key"));
35
36 // Test a valid URL with 2 values of the key we are searching for.
37 const std::string valid_url_two_keys =
38 "http://www.google.com?key=foo&key=bar";
39 EXPECT_EQ("foo", GetValueForKeyInUrlPathQuery(valid_url_two_keys, "key"));
40 }
41
23 } // namespace url_utils 42 } // namespace url_utils
24 43
25 } // namespace dom_distiller 44 } // namespace dom_distiller
OLDNEW
« no previous file with comments | « components/dom_distiller/core/url_utils_android.cc ('k') | components/dom_distiller/core/viewer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698