blob: 9de0b881d75d4dde8a8277d61c5c96b95c50c7e8 [file] [log] [blame]
[email protected]f60b55b62010-04-27 05:26:491// Copyright (c) 2010 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
5#include "chrome/browser/google_url_tracker.h"
6#include "testing/gtest/include/gtest/gtest.h"
7
[email protected]801c3df2008-07-29 00:46:488TEST(GoogleURLTrackerTest, CheckAndConvertURL) {
initial.commit09911bf2008-07-26 23:55:299 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]f60b55b62010-04-27 05:26:4925 { "http://wifi.corp.google.com/", false, "" },
initial.commit09911bf2008-07-26 23:55:2926 };
27
[email protected]85e0f1f2008-12-17 18:30:2828 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) {
initial.commit09911bf2008-07-26 23:55:2929 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}