Display new Autofill UI Contents in Views
[chromium-blink-merge.git] / webkit / user_agent / user_agent_unittest.cc
blob9a6058dbc0691e25a69d471c55aba8287f5ff8b2
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.
5 #include "webkit/user_agent/user_agent.h"
7 #include <string>
9 #include "googleurl/src/gurl.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "webkit/tools/test_shell/test_shell_test.h"
13 namespace {
15 class WebkitGlueUserAgentTest : public TestShellTest {
18 bool IsSpoofedUserAgent(const std::string& user_agent) {
19 return user_agent.find("TestShell") == std::string::npos;
22 TEST_F(WebkitGlueUserAgentTest, UserAgentSpoofingHack) {
23 enum Platform {
24 NONE = 0,
25 MACOSX = 1,
26 WIN = 2,
27 OTHER = 4,
30 struct Expected {
31 const char* url;
32 int os_mask;
35 Expected expected[] = {
36 { "http://wwww.google.com", NONE },
37 { "http://www.microsoft.com/getsilverlight", MACOSX },
38 { "http://headlines.yahoo.co.jp/videonews/", MACOSX | WIN },
39 { "http://downloads.yahoo.co.jp/docs/silverlight/", MACOSX },
40 { "http://gyao.yahoo.co.jp/", MACOSX },
41 { "http://weather.yahoo.co.jp/weather/zoomradar/", WIN },
42 { "http://promotion.shopping.yahoo.co.jp/", WIN },
43 { "http://pokemon.kids.yahoo.co.jp", WIN },
45 #if defined(OS_MACOSX)
46 int os_bit = MACOSX;
47 #elif defined(OS_WIN)
48 int os_bit = WIN;
49 #else
50 int os_bit = OTHER;
51 #endif
53 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(expected); ++i) {
54 EXPECT_EQ((expected[i].os_mask & os_bit) != 0,
55 IsSpoofedUserAgent(
56 webkit_glue::GetUserAgent(GURL(expected[i].url))));
60 } // namespace