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

Side by Side Diff: content/browser/devtools/protocol/devtools_protocol_browsertest.cc

Issue 2226323002: Resize DevTools target frames. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use MAYBE_ pattern to disable test on Android. Created 4 years, 4 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
OLDNEW
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
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 frame size (through RWHV) is not supported on Android.
879 #if defined(OS_ANDROID)
880 #define MAYBE_EmulationGetAndSetFrameSize DISABLED_EmulationGetAndSetFrameSize
881 #else
882 #define MAYBE_EmulationGetAndSetFrameSize EmulationGetAndSetFrameSize
883 #endif
884 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest,
885 MAYBE_EmulationGetAndSetFrameSize) {
886 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1);
887 Attach();
888 int width, height = 0;
889
890 // Get default size.
891 SendCommand("Emulation.getFrameSize", nullptr, true);
892 EXPECT_TRUE(result_->GetInteger("width", &width));
893 EXPECT_TRUE(result_->GetInteger("height", &height));
894 EXPECT_SIZE_EQ(shell()->GetShellDefaultSize(), gfx::Size(width, height));
895
896 // Resize frame.
897 gfx::Size new_size(200, 400);
898 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue());
899 params->SetInteger("width", new_size.width());
900 params->SetInteger("height", new_size.height());
901 SendCommand("Emulation.setFrameSize", std::move(params), true);
902 EXPECT_SIZE_EQ(new_size, (shell()->web_contents())
903 ->GetRenderWidgetHostView()
904 ->GetViewBounds()
905 .size());
906
907 // Get updated size.
908 SendCommand("Emulation.getFrameSize", std::move(params), true);
909 EXPECT_TRUE(result_->GetInteger("width", &width));
910 EXPECT_TRUE(result_->GetInteger("height", &height));
911 EXPECT_SIZE_EQ(new_size, gfx::Size(width, height));
912 }
913
871 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, VirtualTimeTest) { 914 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, VirtualTimeTest) {
872 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); 915 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1);
873 Attach(); 916 Attach();
874 917
875 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); 918 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue());
876 params->SetString("policy", "pause"); 919 params->SetString("policy", "pause");
877 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true); 920 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true);
878 921
879 params.reset(new base::DictionaryValue()); 922 params.reset(new base::DictionaryValue());
880 params->SetString("expression", 923 params->SetString("expression",
(...skipping 22 matching lines...) Expand all
903 params->SetString("policy", "advance"); 946 params->SetString("policy", "advance");
904 params->SetInteger("budget", 1000); 947 params->SetInteger("budget", 1000);
905 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true); 948 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true);
906 949
907 WaitForNotification("Emulation.virtualTimeBudgetExpired"); 950 WaitForNotification("Emulation.virtualTimeBudgetExpired");
908 951
909 EXPECT_THAT(console_messages_, ElementsAre("before", "done", "after")); 952 EXPECT_THAT(console_messages_, ElementsAre("before", "done", "after"));
910 } 953 }
911 954
912 } // namespace content 955 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698