[email protected] | f60b55b6 | 2010-04-27 05:26:49 | [diff] [blame] | 1 | // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
| 5 | #include "chrome/browser/google_url_tracker.h" |
| 6 | #include "testing/gtest/include/gtest/gtest.h" |
| 7 | |
[email protected] | 801c3df | 2008-07-29 00:46:48 | [diff] [blame] | 8 | TEST(GoogleURLTrackerTest, CheckAndConvertURL) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 9 | static const struct { |
| 10 | const char* const source_url; |
| 11 | const bool can_convert; |
| 12 | const char* const base_url; |
| 13 | } data[] = { |
| 14 | { "http://www.google.com/", true, "http://www.google.com/", }, |
| 15 | { "http://google.fr/", true, "http://google.fr/", }, |
| 16 | { "http://google.co.uk/", true, "http://google.co.uk/", }, |
| 17 | { "http://www.google.com.by/", true, "http://www.google.com.by/", }, |
| 18 | { "http://www.google.com/ig", true, "http://www.google.com/", }, |
| 19 | { "http://www.google.com/intl/xx", true, "http://www.google.com/intl/xx", }, |
| 20 | { "http://a.b.c.google.com/", true, "http://a.b.c.google.com/", }, |
| 21 | { "http://www.yahoo.com/", false, "", }, |
| 22 | { "http://google.evil.com/", false, "", }, |
| 23 | { "http://google.com.com.com/", false, "", }, |
| 24 | { "http://google/", false, "", }, |
[email protected] | f60b55b6 | 2010-04-27 05:26:49 | [diff] [blame] | 25 | { "http://wifi.corp.google.com/", false, "" }, |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 26 | }; |
| 27 | |
[email protected] | 85e0f1f | 2008-12-17 18:30:28 | [diff] [blame] | 28 | for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 29 | GURL base_url; |
| 30 | const bool can_convert = GoogleURLTracker::CheckAndConvertToGoogleBaseURL( |
| 31 | GURL(data[i].source_url), &base_url); |
| 32 | EXPECT_EQ(data[i].can_convert, can_convert); |
| 33 | EXPECT_STREQ(data[i].base_url, base_url.spec().c_str()); |
| 34 | } |
| 35 | } |