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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/devtools/protocol/devtools_protocol_browsertest.cc
diff --git a/content/browser/devtools/protocol/devtools_protocol_browsertest.cc b/content/browser/devtools/protocol/devtools_protocol_browsertest.cc
index 236874de399dd945b0d9bed9185b21dc9f30fb47..d66b68ee79897208b8cb6aa114ecbae4ad0569ab 100644
--- a/content/browser/devtools/protocol/devtools_protocol_browsertest.cc
+++ b/content/browser/devtools/protocol/devtools_protocol_browsertest.cc
@@ -19,6 +19,7 @@
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/url_constants.h"
#include "content/public/test/browser_test_utils.h"
@@ -33,6 +34,12 @@
#include "ui/compositor/compositor_switches.h"
#include "ui/gfx/codec/png_codec.h"
+#define EXPECT_SIZE_EQ(expected, actual) \
+ do { \
+ EXPECT_EQ((expected).width(), (actual).width()); \
+ EXPECT_EQ((expected).height(), (actual).height()); \
+ } while (false)
+
using testing::ElementsAre;
namespace content {
@@ -868,6 +875,42 @@ IN_PROC_BROWSER_TEST_F(IsolatedDevToolsProtocolTest,
"http://b.com/devtools/control_navigations/meta_tag.html"));
}
+// Setting frame size (through RWHV) is not supported on Android.
+#if defined(OS_ANDROID)
+#define MAYBE_EmulationGetAndSetFrameSize DISABLED_EmulationGetAndSetFrameSize
+#else
+#define MAYBE_EmulationGetAndSetFrameSize EmulationGetAndSetFrameSize
+#endif
+IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest,
+ MAYBE_EmulationGetAndSetFrameSize) {
+ NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1);
+ Attach();
+ int width, height = 0;
+
+ // Get default size.
+ SendCommand("Emulation.getFrameSize", nullptr, true);
+ EXPECT_TRUE(result_->GetInteger("width", &width));
+ EXPECT_TRUE(result_->GetInteger("height", &height));
+ EXPECT_SIZE_EQ(shell()->GetShellDefaultSize(), gfx::Size(width, height));
+
+ // Resize frame.
+ gfx::Size new_size(200, 400);
+ std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue());
+ params->SetInteger("width", new_size.width());
+ params->SetInteger("height", new_size.height());
+ SendCommand("Emulation.setFrameSize", std::move(params), true);
+ EXPECT_SIZE_EQ(new_size, (shell()->web_contents())
+ ->GetRenderWidgetHostView()
+ ->GetViewBounds()
+ .size());
+
+ // Get updated size.
+ SendCommand("Emulation.getFrameSize", std::move(params), true);
+ EXPECT_TRUE(result_->GetInteger("width", &width));
+ EXPECT_TRUE(result_->GetInteger("height", &height));
+ EXPECT_SIZE_EQ(new_size, gfx::Size(width, height));
+}
+
IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, VirtualTimeTest) {
NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1);
Attach();

Powered by Google App Engine
This is Rietveld 408576698