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

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

Issue 1898633006: headless: Fix handling of replies without any parameters (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « headless/lib/browser/headless_devtools_client_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/public/test/browser_test.h" 7 #include "content/public/test/browser_test.h"
8 #include "headless/public/domains/page.h" 8 #include "headless/public/domains/page.h"
9 #include "headless/public/domains/runtime.h" 9 #include "headless/public/domains/runtime.h"
10 #include "headless/public/headless_browser.h" 10 #include "headless/public/headless_browser.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 int value; 103 int value;
104 EXPECT_TRUE(result->GetResult()->HasValue()); 104 EXPECT_TRUE(result->GetResult()->HasValue());
105 EXPECT_TRUE(result->GetResult()->GetValue()->GetAsInteger(&value)); 105 EXPECT_TRUE(result->GetResult()->GetValue()->GetAsInteger(&value));
106 EXPECT_EQ(168, value); 106 EXPECT_EQ(168, value);
107 FinishAsynchronousTest(); 107 FinishAsynchronousTest();
108 } 108 }
109 }; 109 };
110 110
111 DEVTOOLS_CLIENT_TEST_F(HeadlessDevToolsClientEvalTest); 111 DEVTOOLS_CLIENT_TEST_F(HeadlessDevToolsClientEvalTest);
112 112
113 class HeadlessDevToolsClientCallbackTest : public HeadlessDevToolsClientTest {
114 public:
115 HeadlessDevToolsClientCallbackTest() : first_result_received_(false) {}
116
117 void RunDevToolsClientTest() override {
118 // Null callback without parameters.
119 devtools_client_->GetRuntime()->Run();
120 // Null callback with parameters.
121 devtools_client_->GetRuntime()->Evaluate("true");
122 // Non-null callback without parameters.
123 devtools_client_->GetRuntime()->Disable(
124 base::Bind(&HeadlessDevToolsClientCallbackTest::OnFirstResult,
125 base::Unretained(this)));
126 // Non-null callback with parameters.
127 devtools_client_->GetRuntime()->Evaluate(
128 "true", base::Bind(&HeadlessDevToolsClientCallbackTest::OnSecondResult,
129 base::Unretained(this)));
130 }
131
132 void OnFirstResult() {
133 EXPECT_FALSE(first_result_received_);
134 first_result_received_ = true;
135 }
136
137 void OnSecondResult(std::unique_ptr<runtime::EvaluateResult> result) {
138 EXPECT_TRUE(first_result_received_);
139 FinishAsynchronousTest();
140 }
141
142 private:
143 bool first_result_received_;
144 };
145
146 DEVTOOLS_CLIENT_TEST_F(HeadlessDevToolsClientCallbackTest);
147
113 } // namespace headless 148 } // namespace headless
OLDNEW
« no previous file with comments | « headless/lib/browser/headless_devtools_client_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698