OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stddef.h> | 5 #include <stddef.h> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "base/base64.h" | 8 #include "base/base64.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
17 #include "content/public/browser/devtools_agent_host.h" | 17 #include "content/public/browser/devtools_agent_host.h" |
18 #include "content/public/browser/javascript_dialog_manager.h" | 18 #include "content/public/browser/javascript_dialog_manager.h" |
19 #include "content/public/browser/navigation_handle.h" | 19 #include "content/public/browser/navigation_handle.h" |
20 #include "content/public/browser/render_frame_host.h" | 20 #include "content/public/browser/render_frame_host.h" |
21 #include "content/public/browser/render_view_host.h" | 21 #include "content/public/browser/render_view_host.h" |
| 22 #include "content/public/browser/render_widget_host_view.h" |
22 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
23 #include "content/public/common/url_constants.h" | 24 #include "content/public/common/url_constants.h" |
24 #include "content/public/test/browser_test_utils.h" | 25 #include "content/public/test/browser_test_utils.h" |
25 #include "content/public/test/content_browser_test.h" | 26 #include "content/public/test/content_browser_test.h" |
26 #include "content/public/test/content_browser_test_utils.h" | 27 #include "content/public/test/content_browser_test_utils.h" |
27 #include "content/public/test/test_navigation_observer.h" | 28 #include "content/public/test/test_navigation_observer.h" |
28 #include "content/shell/browser/shell.h" | 29 #include "content/shell/browser/shell.h" |
29 #include "net/dns/mock_host_resolver.h" | 30 #include "net/dns/mock_host_resolver.h" |
30 #include "net/test/embedded_test_server/embedded_test_server.h" | 31 #include "net/test/embedded_test_server/embedded_test_server.h" |
31 #include "testing/gmock/include/gmock/gmock.h" | 32 #include "testing/gmock/include/gmock/gmock.h" |
32 #include "third_party/skia/include/core/SkBitmap.h" | 33 #include "third_party/skia/include/core/SkBitmap.h" |
33 #include "ui/compositor/compositor_switches.h" | 34 #include "ui/compositor/compositor_switches.h" |
34 #include "ui/gfx/codec/png_codec.h" | 35 #include "ui/gfx/codec/png_codec.h" |
35 | 36 |
| 37 #define EXPECT_SIZE_EQ(expected, actual) \ |
| 38 do { \ |
| 39 EXPECT_EQ((expected).width(), (actual).width()); \ |
| 40 EXPECT_EQ((expected).height(), (actual).height()); \ |
| 41 } while (false) |
| 42 |
36 using testing::ElementsAre; | 43 using testing::ElementsAre; |
37 | 44 |
38 namespace content { | 45 namespace content { |
39 | 46 |
40 namespace { | 47 namespace { |
41 | 48 |
42 const char kIdParam[] = "id"; | 49 const char kIdParam[] = "id"; |
43 const char kMethodParam[] = "method"; | 50 const char kMethodParam[] = "method"; |
44 const char kParamsParam[] = "params"; | 51 const char kParamsParam[] = "params"; |
45 | 52 |
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 | 868 |
862 // Make sure each frame has the expected url. | 869 // Make sure each frame has the expected url. |
863 EXPECT_THAT( | 870 EXPECT_THAT( |
864 GetAllFrameUrls(), | 871 GetAllFrameUrls(), |
865 ElementsAre("http://127.0.0.1/devtools/control_navigations/" | 872 ElementsAre("http://127.0.0.1/devtools/control_navigations/" |
866 "iframe_navigation.html", | 873 "iframe_navigation.html", |
867 "http://a.com/devtools/navigation.html", | 874 "http://a.com/devtools/navigation.html", |
868 "http://b.com/devtools/control_navigations/meta_tag.html")); | 875 "http://b.com/devtools/control_navigations/meta_tag.html")); |
869 } | 876 } |
870 | 877 |
| 878 // Setting RWHV size is not supported on Android. |
| 879 #if defined(OS_ANDROID) |
| 880 #define MAYBE_EmulationSetVisibleSize DISABLED_EmulationSetVisibleSize |
| 881 #else |
| 882 #define MAYBE_EmulationSetVisibleSize EmulationSetVisibleSize |
| 883 #endif |
| 884 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, |
| 885 MAYBE_EmulationSetVisibleSize) { |
| 886 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); |
| 887 Attach(); |
| 888 gfx::Size new_size(200, 400); |
| 889 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); |
| 890 params->SetInteger("width", new_size.width()); |
| 891 params->SetInteger("height", new_size.height()); |
| 892 SendCommand("Emulation.setVisibleSize", std::move(params), true); |
| 893 EXPECT_SIZE_EQ(new_size, (shell()->web_contents()) |
| 894 ->GetRenderWidgetHostView() |
| 895 ->GetViewBounds() |
| 896 .size()); |
| 897 } |
| 898 |
871 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, VirtualTimeTest) { | 899 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, VirtualTimeTest) { |
872 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); | 900 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); |
873 Attach(); | 901 Attach(); |
874 | 902 |
875 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); | 903 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); |
876 params->SetString("policy", "pause"); | 904 params->SetString("policy", "pause"); |
877 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true); | 905 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true); |
878 | 906 |
879 params.reset(new base::DictionaryValue()); | 907 params.reset(new base::DictionaryValue()); |
880 params->SetString("expression", | 908 params->SetString("expression", |
(...skipping 22 matching lines...) Expand all Loading... |
903 params->SetString("policy", "advance"); | 931 params->SetString("policy", "advance"); |
904 params->SetInteger("budget", 1000); | 932 params->SetInteger("budget", 1000); |
905 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true); | 933 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true); |
906 | 934 |
907 WaitForNotification("Emulation.virtualTimeBudgetExpired"); | 935 WaitForNotification("Emulation.virtualTimeBudgetExpired"); |
908 | 936 |
909 EXPECT_THAT(console_messages_, ElementsAre("before", "done", "after")); | 937 EXPECT_THAT(console_messages_, ElementsAre("before", "done", "after")); |
910 } | 938 } |
911 | 939 |
912 } // namespace content | 940 } // namespace content |
OLD | NEW |