OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/guest_view/web_view/web_view_apitest.h" | 5 #include "extensions/browser/guest_view/web_view/web_view_apitest.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 const char kEmptyResponsePath[] = "/close-socket"; | 38 const char kEmptyResponsePath[] = "/close-socket"; |
39 const char kRedirectResponsePath[] = "/server-redirect"; | 39 const char kRedirectResponsePath[] = "/server-redirect"; |
40 const char kRedirectResponseFullPath[] = "/guest_redirect.html"; | 40 const char kRedirectResponseFullPath[] = "/guest_redirect.html"; |
41 const char kUserAgentRedirectResponsePath[] = "/detect-user-agent"; | 41 const char kUserAgentRedirectResponsePath[] = "/detect-user-agent"; |
42 const char kTestDataDirectory[] = "testDataDirectory"; | 42 const char kTestDataDirectory[] = "testDataDirectory"; |
43 const char kTestServerPort[] = "testServer.port"; | 43 const char kTestServerPort[] = "testServer.port"; |
44 const char kTestWebSocketPort[] = "testWebSocketPort"; | 44 const char kTestWebSocketPort[] = "testWebSocketPort"; |
45 | 45 |
46 class EmptyHttpResponse : public net::test_server::HttpResponse { | 46 class EmptyHttpResponse : public net::test_server::HttpResponse { |
47 public: | 47 public: |
48 virtual std::string ToResponseString() const override { | 48 std::string ToResponseString() const override { return std::string(); } |
49 return std::string(); | |
50 } | |
51 }; | 49 }; |
52 | 50 |
53 // Handles |request| by serving a redirect response if the |User-Agent| is | 51 // Handles |request| by serving a redirect response if the |User-Agent| is |
54 // foobar. | 52 // foobar. |
55 static scoped_ptr<net::test_server::HttpResponse> UserAgentResponseHandler( | 53 static scoped_ptr<net::test_server::HttpResponse> UserAgentResponseHandler( |
56 const std::string& path, | 54 const std::string& path, |
57 const GURL& redirect_target, | 55 const GURL& redirect_target, |
58 const net::test_server::HttpRequest& request) { | 56 const net::test_server::HttpRequest& request) { |
59 if (!StartsWithASCII(path, request.relative_url, true)) | 57 if (!StartsWithASCII(path, request.relative_url, true)) |
60 return scoped_ptr<net::test_server::HttpResponse>(); | 58 return scoped_ptr<net::test_server::HttpResponse>(); |
(...skipping 14 matching lines...) Expand all Loading... |
75 class WebContentsHiddenObserver : public content::WebContentsObserver { | 73 class WebContentsHiddenObserver : public content::WebContentsObserver { |
76 public: | 74 public: |
77 WebContentsHiddenObserver(content::WebContents* web_contents, | 75 WebContentsHiddenObserver(content::WebContents* web_contents, |
78 const base::Closure& hidden_callback) | 76 const base::Closure& hidden_callback) |
79 : WebContentsObserver(web_contents), | 77 : WebContentsObserver(web_contents), |
80 hidden_callback_(hidden_callback), | 78 hidden_callback_(hidden_callback), |
81 hidden_observed_(false) { | 79 hidden_observed_(false) { |
82 } | 80 } |
83 | 81 |
84 // WebContentsObserver. | 82 // WebContentsObserver. |
85 virtual void WasHidden() override { | 83 void WasHidden() override { |
86 hidden_observed_ = true; | 84 hidden_observed_ = true; |
87 hidden_callback_.Run(); | 85 hidden_callback_.Run(); |
88 } | 86 } |
89 | 87 |
90 bool hidden_observed() { return hidden_observed_; } | 88 bool hidden_observed() { return hidden_observed_; } |
91 | 89 |
92 private: | 90 private: |
93 base::Closure hidden_callback_; | 91 base::Closure hidden_callback_; |
94 bool hidden_observed_; | 92 bool hidden_observed_; |
95 | 93 |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 // object, on the webview element, and hanging directly off webview. | 701 // object, on the webview element, and hanging directly off webview. |
704 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebRequestAPIExistence) { | 702 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebRequestAPIExistence) { |
705 RunTest("testWebRequestAPIExistence", "web_view/apitest"); | 703 RunTest("testWebRequestAPIExistence", "web_view/apitest"); |
706 } | 704 } |
707 | 705 |
708 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebRequestAPIGoogleProperty) { | 706 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebRequestAPIGoogleProperty) { |
709 RunTest("testWebRequestAPIGoogleProperty", "web_view/apitest"); | 707 RunTest("testWebRequestAPIGoogleProperty", "web_view/apitest"); |
710 } | 708 } |
711 | 709 |
712 } // namespace extensions | 710 } // namespace extensions |
OLD | NEW |