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

Unified Diff: content/renderer/render_frame_impl_browsertest.cc

Issue 2765443004: AndroidOverlay implementation using Dialog. (Closed)
Patch Set: fixed test 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | content/test/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_frame_impl_browsertest.cc
diff --git a/content/renderer/render_frame_impl_browsertest.cc b/content/renderer/render_frame_impl_browsertest.cc
index eb36fb2ac00531ddee47f43c47a1d3857eb2f237..dfc8d8ab87fd2c2e5da0e5001195a4f6e39590e8 100644
--- a/content/renderer/render_frame_impl_browsertest.cc
+++ b/content/renderer/render_frame_impl_browsertest.cc
@@ -104,6 +104,14 @@ class RenderFrameImplTest : public RenderViewTest {
return frame_->render_widget_.get();
}
+#if defined(OS_ANDROID)
+ void ReceiveOverlayRoutingToken(const base::UnguessableToken& token) {
+ overlay_routing_token_ = token;
+ }
+
+ base::Optional<base::UnguessableToken> overlay_routing_token_;
+#endif
+
private:
RenderFrameImpl* frame_;
FakeCompositorDependencies compositor_deps_;
@@ -370,4 +378,52 @@ TEST_F(RenderFrameImplTest, NoCrashWhenDeletingFrameDuringFind) {
frame()->OnMessageReceived(delete_message);
}
+#if defined(OS_ANDROID)
+// Verify that RFI defers token requests if the token hasn't arrived yet.
+TEST_F(RenderFrameImplTest, TestOverlayRoutingTokenSendsLater) {
+ ASSERT_FALSE(overlay_routing_token_.has_value());
+
+ frame()->RequestOverlayRoutingToken(
+ base::Bind(&RenderFrameImplTest::ReceiveOverlayRoutingToken,
+ base::Unretained(this)));
+ ASSERT_FALSE(overlay_routing_token_.has_value());
+
+ // The host should receive a request for it sent to the frame.
+ const IPC::Message* msg = render_thread_->sink().GetFirstMessageMatching(
+ FrameHostMsg_RequestOverlayRoutingToken::ID);
+ EXPECT_TRUE(msg);
+
+ // Send a token.
+ base::UnguessableToken token = base::UnguessableToken::Create();
+ FrameMsg_SetOverlayRoutingToken token_message(0, token);
+ frame()->OnMessageReceived(token_message);
+
+ ProcessPendingMessages();
+ ASSERT_TRUE(overlay_routing_token_.has_value());
+ ASSERT_EQ(overlay_routing_token_.value(), token);
+}
+
+// Verify that RFI sends tokens if they're already available.
+TEST_F(RenderFrameImplTest, TestOverlayRoutingTokenSendsNow) {
+ ASSERT_FALSE(overlay_routing_token_.has_value());
+ base::UnguessableToken token = base::UnguessableToken::Create();
+ FrameMsg_SetOverlayRoutingToken token_message(0, token);
+ frame()->OnMessageReceived(token_message);
+
+ // The frame now has a token. We don't care if it sends the token before
+ // returning or posts a message.
+ ProcessPendingMessages();
+ frame()->RequestOverlayRoutingToken(
+ base::Bind(&RenderFrameImplTest::ReceiveOverlayRoutingToken,
+ base::Unretained(this)));
+ ASSERT_TRUE(overlay_routing_token_.has_value());
+ ASSERT_EQ(overlay_routing_token_.value(), token);
+
+ // Since the token already arrived, a request for it shouldn't be sent.
+ const IPC::Message* msg = render_thread_->sink().GetFirstMessageMatching(
+ FrameHostMsg_RequestOverlayRoutingToken::ID);
+ EXPECT_FALSE(msg);
+}
+#endif
+
} // namespace
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | content/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698