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

Side by Side Diff: webkit/user_agent/user_agent_unittest.cc

Issue 10869073: Split user agent code out of the 'glue' target (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to trunk Created 8 years, 3 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 | « webkit/user_agent/user_agent.cc ('k') | webkit/user_agent/user_agent_util.h » ('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 "webkit/user_agent/user_agent.h"
6
7 #include <string>
8
9 #include "googleurl/src/gurl.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "webkit/tools/test_shell/test_shell_test.h"
12
13 namespace {
14
15 class WebkitGlueUserAgentTest : public TestShellTest {
16 };
17
18 bool IsSpoofedUserAgent(const std::string& user_agent) {
19 return user_agent.find("TestShell") == std::string::npos;
20 }
21
22 TEST_F(WebkitGlueUserAgentTest, UserAgentSpoofingHack) {
23 enum Platform {
24 NONE = 0,
25 MACOSX = 1,
26 WIN = 2,
27 OTHER = 4,
28 };
29
30 struct Expected {
31 const char* url;
32 int os_mask;
33 };
34
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 },
44 };
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
52
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))));
57 }
58 }
59
60 } // namespace
OLDNEW
« no previous file with comments | « webkit/user_agent/user_agent.cc ('k') | webkit/user_agent/user_agent_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698