| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 <utility> | 5 #include <utility> |
| 6 | 6 |
| 7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "content/public/browser/navigation_controller.h" | 10 #include "content/public/browser/navigation_controller.h" |
| 11 #include "content/public/browser/notification_service.h" | 11 #include "content/public/browser/notification_service.h" |
| 12 #include "content/public/browser/notification_types.h" | 12 #include "content/public/browser/notification_types.h" |
| 13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 14 #include "content/public/common/url_constants.h" | 14 #include "content/public/common/url_constants.h" |
| 15 #include "content/public/test/browser_test_utils.h" | 15 #include "content/public/test/browser_test_utils.h" |
| 16 #include "content/public/test/content_browser_test.h" | 16 #include "content/public/test/content_browser_test.h" |
| 17 #include "content/public/test/content_browser_test_utils.h" | 17 #include "content/public/test/content_browser_test_utils.h" |
| 18 #include "content/public/test/test_utils.h" | 18 #include "content/public/test/test_utils.h" |
| 19 #include "content/shell/browser/shell.h" | 19 #include "content/shell/browser/shell.h" |
| 20 #include "net/test/embedded_test_server/embedded_test_server.h" | 20 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 21 #include "net/test/embedded_test_server/http_request.h" | 21 #include "net/test/embedded_test_server/http_request.h" |
| 22 #include "net/test/embedded_test_server/http_response.h" | 22 #include "net/test/embedded_test_server/http_response.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 24 | 24 |
| 25 namespace content { | 25 namespace content { |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 // Handles |request| by serving a response with title set to request contents. | 29 // Handles |request| by serving a response with title set to request contents. |
| 30 scoped_ptr<net::test_server::HttpResponse> HandleEchoTitleRequest( | 30 std::unique_ptr<net::test_server::HttpResponse> HandleEchoTitleRequest( |
| 31 const std::string& echotitle_path, | 31 const std::string& echotitle_path, |
| 32 const net::test_server::HttpRequest& request) { | 32 const net::test_server::HttpRequest& request) { |
| 33 if (!base::StartsWith(request.relative_url, echotitle_path, | 33 if (!base::StartsWith(request.relative_url, echotitle_path, |
| 34 base::CompareCase::SENSITIVE)) | 34 base::CompareCase::SENSITIVE)) |
| 35 return scoped_ptr<net::test_server::HttpResponse>(); | 35 return std::unique_ptr<net::test_server::HttpResponse>(); |
| 36 | 36 |
| 37 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 37 std::unique_ptr<net::test_server::BasicHttpResponse> http_response( |
| 38 new net::test_server::BasicHttpResponse); | 38 new net::test_server::BasicHttpResponse); |
| 39 http_response->set_code(net::HTTP_OK); | 39 http_response->set_code(net::HTTP_OK); |
| 40 http_response->set_content( | 40 http_response->set_content( |
| 41 base::StringPrintf( | 41 base::StringPrintf( |
| 42 "<html><head><title>%s</title></head></html>", | 42 "<html><head><title>%s</title></head></html>", |
| 43 request.content.c_str())); | 43 request.content.c_str())); |
| 44 return std::move(http_response); | 44 return std::move(http_response); |
| 45 } | 45 } |
| 46 | 46 |
| 47 } // namespace | 47 } // namespace |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 NavigateToURL(shell(), GetURL("title2.html")); | 493 NavigateToURL(shell(), GetURL("title2.html")); |
| 494 | 494 |
| 495 ASSERT_TRUE(ExecuteScriptAndExtractInt( | 495 ASSERT_TRUE(ExecuteScriptAndExtractInt( |
| 496 shell()->web_contents(), | 496 shell()->web_contents(), |
| 497 "domAutomationController.send(history.length)", | 497 "domAutomationController.send(history.length)", |
| 498 &length)); | 498 &length)); |
| 499 EXPECT_EQ(2, length); | 499 EXPECT_EQ(2, length); |
| 500 } | 500 } |
| 501 | 501 |
| 502 } // namespace content | 502 } // namespace content |
| OLD | NEW |