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

Side by Side Diff: content/renderer/render_frame_impl_browsertest.cc

Issue 1273183002: Fix invalid C-style cast in RenderFrameImplTest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 5 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 | 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/debug/leak_annotations.h" 6 #include "base/debug/leak_annotations.h"
7 #include "content/common/frame_messages.h" 7 #include "content/common/frame_messages.h"
8 #include "content/common/view_messages.h" 8 #include "content/common/view_messages.h"
9 #include "content/public/test/frame_load_waiter.h" 9 #include "content/public/test/frame_load_waiter.h"
10 #include "content/public/test/render_view_test.h" 10 #include "content/public/test/render_view_test.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 #else 103 #else
104 #define MAYBE_SubframeWidget SubframeWidget 104 #define MAYBE_SubframeWidget SubframeWidget
105 #define MAYBE_FrameResize FrameResize 105 #define MAYBE_FrameResize FrameResize
106 #define MAYBE_FrameWasShown FrameWasShown 106 #define MAYBE_FrameWasShown FrameWasShown
107 #endif 107 #endif
108 108
109 // Verify that a frame with a RenderFrameProxy as a parent has its own 109 // Verify that a frame with a RenderFrameProxy as a parent has its own
110 // RenderWidget. 110 // RenderWidget.
111 TEST_F(RenderFrameImplTest, MAYBE_SubframeWidget) { 111 TEST_F(RenderFrameImplTest, MAYBE_SubframeWidget) {
112 EXPECT_TRUE(frame_widget()); 112 EXPECT_TRUE(frame_widget());
113 EXPECT_NE(frame_widget(), (content::RenderWidget*)view_); 113 // We can't convert to RenderWidget* directly, because
114 // it and content::RenderView are two unrelated base classes
nasko 2015/08/06 21:05:30 The content:: prefixes are still in the comments.
115 // of content::RenderViewImpl. If a class has multiple base classes,
116 // each base class pointer will be distinct, and direct casts
117 // between unrelated base classes are undefined, even if they share
118 // a common derived class. The compiler has no way in general of
119 // determining the displacement between the two classes, so these
120 // types of casts cannot be implemented in a type safe way.
121 // To overcome this, we make two legal static casts:
122 // first, downcast from RenderView* to RenderViewImpl*,
123 // then upcast from RenderViewImpl* to RenderWidget*.
124 EXPECT_NE(frame_widget(),
125 static_cast<content::RenderWidget*>(
126 static_cast<content::RenderViewImpl*>((view_))));
114 } 127 }
115 128
116 // Verify a subframe RenderWidget properly processes its viewport being 129 // Verify a subframe RenderWidget properly processes its viewport being
117 // resized. 130 // resized.
118 TEST_F(RenderFrameImplTest, MAYBE_FrameResize) { 131 TEST_F(RenderFrameImplTest, MAYBE_FrameResize) {
119 ViewMsg_Resize_Params resize_params; 132 ViewMsg_Resize_Params resize_params;
120 gfx::Size size(200, 200); 133 gfx::Size size(200, 200);
121 resize_params.screen_info = blink::WebScreenInfo(); 134 resize_params.screen_info = blink::WebScreenInfo();
122 resize_params.new_size = size; 135 resize_params.new_size = size;
123 resize_params.physical_backing_size = size; 136 resize_params.physical_backing_size = size;
(...skipping 13 matching lines...) Expand all
137 RenderFrameTestObserver observer(frame()); 150 RenderFrameTestObserver observer(frame());
138 151
139 ViewMsg_WasShown was_shown_message(0, true, ui::LatencyInfo()); 152 ViewMsg_WasShown was_shown_message(0, true, ui::LatencyInfo());
140 frame_widget()->OnMessageReceived(was_shown_message); 153 frame_widget()->OnMessageReceived(was_shown_message);
141 154
142 EXPECT_FALSE(frame_widget()->is_hidden()); 155 EXPECT_FALSE(frame_widget()->is_hidden());
143 EXPECT_TRUE(observer.visible()); 156 EXPECT_TRUE(observer.visible());
144 } 157 }
145 158
146 } // namespace 159 } // namespace
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698