Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <windows.h> | 5 #include <windows.h> |
| 6 #include <atlsecurity.h> | 6 #include <atlsecurity.h> |
| 7 #include <shellapi.h> | 7 #include <shellapi.h> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_handle.h" | 14 #include "base/memory/scoped_handle.h" |
| 15 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
| 16 #include "base/path_service.h" | 16 #include "base/path_service.h" |
| 17 #include "base/process_util.h" | 17 #include "base/process_util.h" |
| 18 #include "base/task.h" | 18 #include "base/task.h" |
| 19 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
| 20 #include "net/base/net_util.h" | 20 #include "net/base/net_util.h" |
| 21 | 21 |
| 22 #include "chrome/browser/automation/url_request_automation_job.h" | 22 #include "chrome/browser/automation/url_request_automation_job.h" |
| 23 #include "chrome/common/chrome_version_info.h" | |
| 23 #include "chrome_frame/chrome_frame_automation.h" | 24 #include "chrome_frame/chrome_frame_automation.h" |
| 24 #include "chrome_frame/chrome_frame_delegate.h" | 25 #include "chrome_frame/chrome_frame_delegate.h" |
| 25 #include "chrome_frame/html_utils.h" | 26 #include "chrome_frame/html_utils.h" |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
| 27 #include "webkit/glue/webkit_glue.h" | 28 #include "webkit/glue/user_agent.h" |
| 28 | 29 |
| 29 const char kChromeFrameUserAgent[] = "chromeframe"; | 30 const char kChromeFrameUserAgent[] = "chromeframe"; |
| 30 | 31 |
| 31 class HtmlUtilUnittest : public testing::Test { | 32 class HtmlUtilUnittest : public testing::Test { |
| 32 protected: | 33 protected: |
| 33 // Constructor | 34 // Constructor |
| 34 HtmlUtilUnittest() {} | 35 HtmlUtilUnittest() {} |
| 35 | 36 |
| 36 // Returns the test path given a test case. | 37 // Returns the test path given a test case. |
| 37 virtual bool GetTestPath(const std::string& test_case, FilePath* path) { | 38 virtual bool GetTestPath(const std::string& test_case, FilePath* path) { |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 396 } | 397 } |
| 397 | 398 |
| 398 TEST_F(HtmlUtilUnittest, GetDefaultUserAgentHeaderWithCFTag) { | 399 TEST_F(HtmlUtilUnittest, GetDefaultUserAgentHeaderWithCFTag) { |
| 399 std::string ua(http_utils::GetDefaultUserAgentHeaderWithCFTag()); | 400 std::string ua(http_utils::GetDefaultUserAgentHeaderWithCFTag()); |
| 400 EXPECT_NE(0u, ua.length()); | 401 EXPECT_NE(0u, ua.length()); |
| 401 EXPECT_NE(std::string::npos, ua.find("Mozilla")); | 402 EXPECT_NE(std::string::npos, ua.find("Mozilla")); |
| 402 EXPECT_NE(std::string::npos, ua.find(kChromeFrameUserAgent)); | 403 EXPECT_NE(std::string::npos, ua.find(kChromeFrameUserAgent)); |
| 403 } | 404 } |
| 404 | 405 |
| 405 TEST_F(HtmlUtilUnittest, GetChromeUserAgent) { | 406 TEST_F(HtmlUtilUnittest, GetChromeUserAgent) { |
| 406 std::string chrome_ua; | 407 |
|
tommi (sloooow) - chröme
2011/09/22 08:58:46
nit: remove empty line
| |
| 407 chrome_ua = webkit_glue::BuildUserAgent(false); | 408 // This code is duplicated from chrome_content_client.cc to avoid |
| 408 EXPECT_FALSE(chrome_ua.empty()); | 409 // introducing a link-time dependency on chrome_common. |
| 410 chrome::VersionInfo version_info; | |
| 411 std::string product("Chrome/"); | |
| 412 product += version_info.is_valid() ? version_info.Version() : "0.0.0.0"; | |
| 413 std::string chrome_ua = webkit_glue::BuildUserAgentFromProduct(product); | |
|
tommi (sloooow) - chröme
2011/09/22 08:58:46
nit: constructor syntax for complex types as is do
| |
| 414 | |
| 409 const char* ua = http_utils::GetChromeUserAgent(); | 415 const char* ua = http_utils::GetChromeUserAgent(); |
| 410 EXPECT_EQ(0, chrome_ua.compare(ua)); | 416 EXPECT_EQ(ua, chrome_ua); |
| 411 } | 417 } |
| 412 | 418 |
| 413 TEST_F(HtmlUtilUnittest, GetDefaultUserAgent) { | 419 TEST_F(HtmlUtilUnittest, GetDefaultUserAgent) { |
| 414 std::string ua(http_utils::GetDefaultUserAgent()); | 420 std::string ua(http_utils::GetDefaultUserAgent()); |
| 415 EXPECT_NE(0u, ua.length()); | 421 EXPECT_NE(0u, ua.length()); |
| 416 EXPECT_NE(std::string::npos, ua.find("Mozilla")); | 422 EXPECT_NE(std::string::npos, ua.find("Mozilla")); |
| 417 } | 423 } |
| 418 | 424 |
| 419 TEST_F(HtmlUtilUnittest, GetChromeFrameUserAgent) { | 425 TEST_F(HtmlUtilUnittest, GetChromeFrameUserAgent) { |
| 420 const char* call1 = http_utils::GetChromeFrameUserAgent(); | 426 const char* call1 = http_utils::GetChromeFrameUserAgent(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 474 "Content-Length: 42\r\n" | 480 "Content-Length: 42\r\n" |
| 475 "X-Frame-Options: SAMEORIGIN\r\n")); | 481 "X-Frame-Options: SAMEORIGIN\r\n")); |
| 476 EXPECT_TRUE(http_utils::HasFrameBustingHeader( | 482 EXPECT_TRUE(http_utils::HasFrameBustingHeader( |
| 477 "X-Frame-Options: deny\r\n" | 483 "X-Frame-Options: deny\r\n" |
| 478 "X-Frame-Options: ALLOWall\r\n" | 484 "X-Frame-Options: ALLOWall\r\n" |
| 479 "Content-Length: 42\r\n")); | 485 "Content-Length: 42\r\n")); |
| 480 EXPECT_TRUE(http_utils::HasFrameBustingHeader( | 486 EXPECT_TRUE(http_utils::HasFrameBustingHeader( |
| 481 "X-Frame-Options: SAMEORIGIN\r\n" | 487 "X-Frame-Options: SAMEORIGIN\r\n" |
| 482 "X-Frame-Options: ALLOWall\r\n")); | 488 "X-Frame-Options: ALLOWall\r\n")); |
| 483 } | 489 } |
| OLD | NEW |