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

Side by Side Diff: headless/lib/headless_devtools_client_browsertest.cc

Issue 2812253002: Headless: Support sending and receiving of raw protocol messages (Closed)
Patch Set: Fix tests Created 3 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <memory> 5 #include <memory>
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "content/public/browser/render_widget_host_view.h" 9 #include "content/public/browser/render_widget_host_view.h"
10 #include "content/public/browser/web_contents.h" 10 #include "content/public/browser/web_contents.h"
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 EXPECT_FALSE(test_handler_->last_http_request_headers().HasHeader( 980 EXPECT_FALSE(test_handler_->last_http_request_headers().HasHeader(
981 kDevToolsEmulateNetworkConditionsClientId)); 981 kDevToolsEmulateNetworkConditionsClientId));
982 FinishAsynchronousTest(); 982 FinishAsynchronousTest();
983 } 983 }
984 984
985 TestProtocolHandler* test_handler_; // NOT OWNED 985 TestProtocolHandler* test_handler_; // NOT OWNED
986 }; 986 };
987 987
988 HEADLESS_ASYNC_DEVTOOLED_TEST_F(DevToolsHeaderStrippingTest); 988 HEADLESS_ASYNC_DEVTOOLED_TEST_F(DevToolsHeaderStrippingTest);
989 989
990 class RawDevtoolsProtocolTest
991 : public HeadlessAsyncDevTooledBrowserTest,
992 public HeadlessDevToolsClient::RawProtocolListener {
993 public:
994 void RunDevTooledTest() override {
995 devtools_client_->SetRawProtocolListener(this);
996
997 base::DictionaryValue message;
998 message.SetInteger("id", devtools_client_->GetNextRawDevToolsMessageId());
999 message.SetString("method", "Runtime.evaluate");
1000 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue());
1001 params->SetString("expression", "1+1");
1002 message.Set("params", std::move(params));
1003 devtools_client_->SendRawDevToolsMessage(message);
1004 }
1005
1006 bool OnProtocolMessage(const std::string& devtools_agent_host_id,
1007 const std::string& json_message,
1008 const base::DictionaryValue& parsed_message) override {
1009 EXPECT_EQ(
1010 "{\"id\":1,\"result\":{\"result\":{\"type\":\"number\","
1011 "\"value\":2,\"description\":\"2\"}}}",
1012 json_message);
1013
1014 int frame_tree_node_id = 0;
1015 EXPECT_TRUE(web_contents_->GetFrameTreeNodeIdForDevToolsAgentHostId(
1016 devtools_agent_host_id, &frame_tree_node_id));
1017 EXPECT_NE(0, frame_tree_node_id);
1018 FinishAsynchronousTest();
1019 return true;
1020 }
1021 };
1022
1023 HEADLESS_ASYNC_DEVTOOLED_TEST_F(RawDevtoolsProtocolTest);
1024
990 } // namespace headless 1025 } // namespace headless
OLDNEW
« no previous file with comments | « headless/lib/browser/headless_web_contents_impl.cc ('k') | headless/public/headless_devtools_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698