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

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: No support for setFrameSize 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
« no previous file with comments | « no previous file | content/browser/devtools/protocol/emulation_handler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Setting frame size (through RWHV) is not supported on Android.
857 #if !defined(OS_ANDROID)
Sami 2016/08/18 14:24:53 nit: Please use the MAYBE_ pattern[1] to disable t
858 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, EmulationGetAndSetFrameSize) {
859 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1);
860 Attach();
861 int width, height = 0;
862
863 // Get default size.
864 SendCommand("Emulation.getFrameSize", nullptr, true);
865 EXPECT_TRUE(result_->GetInteger("width", &width));
866 EXPECT_TRUE(result_->GetInteger("height", &height));
867 EXPECT_SIZE_EQ(shell()->GetShellDefaultSize(), gfx::Size(width, height));
868
869 // Resize frame.
870 gfx::Size new_size(200, 400);
871 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue());
872 params->SetInteger("width", new_size.width());
873 params->SetInteger("height", new_size.height());
874 SendCommand("Emulation.setFrameSize", std::move(params), true);
875 EXPECT_SIZE_EQ(new_size, (shell()->web_contents())
876 ->GetRenderWidgetHostView()
877 ->GetViewBounds()
878 .size());
879
880 // Get updated size.
881 SendCommand("Emulation.getFrameSize", std::move(params), true);
882 EXPECT_TRUE(result_->GetInteger("width", &width));
883 EXPECT_TRUE(result_->GetInteger("height", &height));
884 EXPECT_SIZE_EQ(new_size, gfx::Size(width, height));
885 }
886 #endif // !defined(OS_ANDROID)
887
849 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, VirtualTimeTest) { 888 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, VirtualTimeTest) {
850 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); 889 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1);
851 Attach(); 890 Attach();
852 891
853 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); 892 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue());
854 params->SetString("policy", "pause"); 893 params->SetString("policy", "pause");
855 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true); 894 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true);
856 895
857 params.reset(new base::DictionaryValue()); 896 params.reset(new base::DictionaryValue());
858 params->SetString("expression", 897 params->SetString("expression",
(...skipping 22 matching lines...) Expand all
881 params->SetString("policy", "advance"); 920 params->SetString("policy", "advance");
882 params->SetInteger("budget", 1000); 921 params->SetInteger("budget", 1000);
883 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true); 922 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true);
884 923
885 WaitForNotification("Emulation.virtualTimeBudgetExpired"); 924 WaitForNotification("Emulation.virtualTimeBudgetExpired");
886 925
887 EXPECT_THAT(console_messages_, ElementsAre("before", "done", "after")); 926 EXPECT_THAT(console_messages_, ElementsAre("before", "done", "after"));
888 } 927 }
889 928
890 } // namespace content 929 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/devtools/protocol/emulation_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698