OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/public/test/browser_test_utils.h" | 5 #include "content/public/test/browser_test_utils.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1052 } | 1052 } |
1053 | 1053 |
1054 bool WebContentsAddedObserver::RenderViewCreatedCalled() { | 1054 bool WebContentsAddedObserver::RenderViewCreatedCalled() { |
1055 if (child_observer_) { | 1055 if (child_observer_) { |
1056 return child_observer_->render_view_created_called_ && | 1056 return child_observer_->render_view_created_called_ && |
1057 child_observer_->main_frame_created_called_; | 1057 child_observer_->main_frame_created_called_; |
1058 } | 1058 } |
1059 return false; | 1059 return false; |
1060 } | 1060 } |
1061 | 1061 |
| 1062 void WaitForFirstFrame(WebContents* web_contents) { |
| 1063 RenderWidgetHostViewBase* rwhv_child = static_cast<RenderWidgetHostViewBase*>( |
| 1064 web_contents->GetRenderWidgetHostView()); |
| 1065 // TODO(wjmaclean): Find a better way to avoid sleeping like this. |
| 1066 while (rwhv_child->RendererFrameNumber() <= 0) { |
| 1067 base::RunLoop run_loop; |
| 1068 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 1069 FROM_HERE, run_loop.QuitClosure(), |
| 1070 base::TimeDelta::FromMilliseconds(10)); |
| 1071 run_loop.Run(); |
| 1072 } |
| 1073 } |
| 1074 |
1062 bool RequestFrame(WebContents* web_contents) { | 1075 bool RequestFrame(WebContents* web_contents) { |
1063 DCHECK(web_contents); | 1076 DCHECK(web_contents); |
1064 return RenderWidgetHostImpl::From( | 1077 return RenderWidgetHostImpl::From( |
1065 web_contents->GetRenderViewHost()->GetWidget()) | 1078 web_contents->GetRenderViewHost()->GetWidget()) |
1066 ->ScheduleComposite(); | 1079 ->ScheduleComposite(); |
1067 } | 1080 } |
1068 | 1081 |
1069 FrameWatcher::FrameWatcher() | 1082 FrameWatcher::FrameWatcher() |
1070 : BrowserMessageFilter(ViewMsgStart), frames_to_wait_(0) { | 1083 : BrowserMessageFilter(ViewMsgStart), frames_to_wait_(0) { |
1071 } | 1084 } |
(...skipping 25 matching lines...) Expand all Loading... |
1097 void FrameWatcher::WaitFrames(int frames_to_wait) { | 1110 void FrameWatcher::WaitFrames(int frames_to_wait) { |
1098 if (frames_to_wait <= 0) | 1111 if (frames_to_wait <= 0) |
1099 return; | 1112 return; |
1100 base::RunLoop run_loop; | 1113 base::RunLoop run_loop; |
1101 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); | 1114 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); |
1102 base::AutoReset<int> reset_frames_to_wait(&frames_to_wait_, frames_to_wait); | 1115 base::AutoReset<int> reset_frames_to_wait(&frames_to_wait_, frames_to_wait); |
1103 run_loop.Run(); | 1116 run_loop.Run(); |
1104 } | 1117 } |
1105 | 1118 |
1106 } // namespace content | 1119 } // namespace content |
OLD | NEW |