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

Unified Diff: android_webview/browser/browser_view_renderer_unittest.cc

Issue 1002013003: Unit Test for WebView animating in and out of screen (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Yet another way to write the test. Created 5 years, 9 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
Index: android_webview/browser/browser_view_renderer_unittest.cc
diff --git a/android_webview/browser/browser_view_renderer_unittest.cc b/android_webview/browser/browser_view_renderer_unittest.cc
index b4a9d42227241cef82d61d71a47608eb57d52001..4dffcd3d0f0d976eecfa7071da1ec64a5e1a19c7 100644
--- a/android_webview/browser/browser_view_renderer_unittest.cc
+++ b/android_webview/browser/browser_view_renderer_unittest.cc
@@ -59,4 +59,79 @@ class ClearViewTest : public RenderingTest {
RENDERING_TEST_F(ClearViewTest);
+class TestAnimateInAndOutOfScreen : public RenderingTest {
+ public:
+ TestAnimateInAndOutOfScreen() : step_(1u) {}
boliu 2015/03/19 00:15:20 We are computer scientists!! We start counting fro
hush (inactive) 2015/03/19 01:02:51 Done. But I can't put it in StartTest because the
+
+ void StartTest() override {
+ new_constraints_ = ParentCompositorDrawConstraints(
+ false, gfx::Transform(), gfx::Rect(window_->surface_size()));
+ new_constraints_.transform.Scale(2.0, 2.0);
+ browser_view_renderer_->SetContinuousInvalidate(true);
+ }
+
+ void WillOnDraw() override {
+ if (step_ == 1u) {
+ // Step 1: A single onDraw on screen. The parent draw constraints
+ // of the BVR will updated to be the initial constraints.
+ browser_view_renderer_->SetContinuousInvalidate(false);
+ }
+ if (step_ == 2u) {
+ // Step 2: A single onDrraw off screen. The parent draw constraints of the
+ // BVR will be updated to the new constraints.
+ browser_view_renderer_->PrepareToDraw(gfx::Vector2d(), gfx::Rect());
+ }
+ if (step_ == 3u) {
+ // Step 3: Continuously call onDraw onscreen. End the test when the parent
+ // draw constraints of BVR is updated to initial constraints.
+ browser_view_renderer_->SetContinuousInvalidate(true);
+ }
+ }
+
+ void DidOnDraw(bool success) override { EXPECT_TRUE(success); }
+
+ bool WillDrawOnRT(SharedRendererState* functor,
+ AwDrawGLInfo& draw_info) override {
+ if (browser_view_renderer_->global_visible_rect_for_testing().IsEmpty())
+ return false;
+
+ draw_info.width = window_->surface_size().width();
+ draw_info.height = window_->surface_size().height();
+ draw_info.is_layer = false;
+
+ gfx::Transform transform;
+ if (step_ == 2u)
+ transform = new_constraints_.transform;
+
+ transform.matrix().asColMajorf(draw_info.transform);
+ return true;
+ }
+
+ void ParentDrawConstraintsUpdated() override {
+ ParentCompositorDrawConstraints constraints =
+ browser_view_renderer_->parent_draw_constraints_for_testing();
boliu 2015/03/19 00:15:20 We don't need both ConstraintsUpdated and GetConst
hush (inactive) 2015/03/19 01:02:51 Done.
+ if (step_ == 1u && constraints.Equals(initial_constraints_)) {
+ step_++;
boliu 2015/03/19 00:15:20 Do we get more than one ParentDrawConstraintsUpdat
hush (inactive) 2015/03/19 01:02:51 By 'validating' I guess you mean EXPECT_TRUE? I'm
boliu 2015/03/19 01:05:33 I don't understand why there will be multiple Pare
+ }
+
+ if (step_ == 2u && constraints.Equals(new_constraints_)) {
+ step_++;
+ PostInvalidate();
+ }
+
+ if (step_ == 3u && constraints.Equals(initial_constraints_)) {
+ step_++;
+ browser_view_renderer_->SetContinuousInvalidate(false);
+ EndTest();
+ }
+ }
+
+ private:
+ size_t step_;
+ ParentCompositorDrawConstraints initial_constraints_;
+ ParentCompositorDrawConstraints new_constraints_;
+};
+
+RENDERING_TEST_F(TestAnimateInAndOutOfScreen);
+
} // namespace android_webview
« no previous file with comments | « android_webview/browser/browser_view_renderer_client.h ('k') | android_webview/browser/hardware_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698