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

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: move command to Emulation, pull out other fixes into separate patch. 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 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 846
840 // Make sure each frame has the expected url. 847 // Make sure each frame has the expected url.
841 EXPECT_THAT( 848 EXPECT_THAT(
842 GetAllFrameUrls(), 849 GetAllFrameUrls(),
843 ElementsAre("http://127.0.0.1/devtools/control_navigations/" 850 ElementsAre("http://127.0.0.1/devtools/control_navigations/"
844 "iframe_navigation.html", 851 "iframe_navigation.html",
845 "http://a.com/devtools/navigation.html", 852 "http://a.com/devtools/navigation.html",
846 "http://b.com/devtools/control_navigations/meta_tag.html")); 853 "http://b.com/devtools/control_navigations/meta_tag.html"));
847 } 854 }
848 855
856 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, EmulationGetAndSetFrameSize) {
857 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1);
858 Attach();
859 int width, height = 0;
860
861 // Get default size.
862 SendCommand("Emulation.getFrameSize", nullptr, true);
863 EXPECT_TRUE(result_->GetInteger("width", &width));
864 EXPECT_TRUE(result_->GetInteger("height", &height));
865 EXPECT_SIZE_EQ(shell()->GetShellDefaultSize(), gfx::Size(width, height));
866
867 // Resize frame.
868 gfx::Size new_size(200, 400);
869 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue());
870 params->SetInteger("width", new_size.width());
871 params->SetInteger("height", new_size.height());
872 SendCommand("Emulation.setFrameSize", std::move(params), true);
873 EXPECT_SIZE_EQ(new_size, (shell()->web_contents())
874 ->GetRenderWidgetHostView()
875 ->GetViewBounds()
876 .size());
877
878 // Get updated size.
879 SendCommand("Emulation.getFrameSize", std::move(params), true);
880 EXPECT_TRUE(result_->GetInteger("width", &width));
881 EXPECT_TRUE(result_->GetInteger("height", &height));
882 EXPECT_SIZE_EQ(new_size, gfx::Size(width, height));
883 }
884
849 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, VirtualTimeTest) { 885 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, VirtualTimeTest) {
850 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); 886 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1);
851 Attach(); 887 Attach();
852 888
853 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); 889 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue());
854 params->SetString("policy", "pause"); 890 params->SetString("policy", "pause");
855 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true); 891 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true);
856 892
857 params.reset(new base::DictionaryValue()); 893 params.reset(new base::DictionaryValue());
858 params->SetString("expression", 894 params->SetString("expression",
(...skipping 22 matching lines...) Expand all
881 params->SetString("policy", "advance"); 917 params->SetString("policy", "advance");
882 params->SetInteger("budget", 1000); 918 params->SetInteger("budget", 1000);
883 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true); 919 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true);
884 920
885 WaitForNotification("Emulation.virtualTimeBudgetExpired"); 921 WaitForNotification("Emulation.virtualTimeBudgetExpired");
886 922
887 EXPECT_THAT(console_messages_, ElementsAre("before", "done", "after")); 923 EXPECT_THAT(console_messages_, ElementsAre("before", "done", "after"));
888 } 924 }
889 925
890 } // namespace content 926 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698