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

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: 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
« no previous file with comments | « android_webview/browser/browser_view_renderer.cc ('k') | android_webview/browser/hardware_renderer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..2d7be5e14c8af7c87dbb570f8d25449c558ab7ac 100644
--- a/android_webview/browser/browser_view_renderer_unittest.cc
+++ b/android_webview/browser/browser_view_renderer_unittest.cc
@@ -59,4 +59,104 @@ class ClearViewTest : public RenderingTest {
RENDERING_TEST_F(ClearViewTest);
+class TestForceInvalidateWithEmptyGlobalVisibleRect : public RenderingTest {
+ public:
+ TestForceInvalidateWithEmptyGlobalVisibleRect() : on_draw_count_(0u) {}
+
+ void StartTest() override {
+ browser_view_renderer_->SetContinuousInvalidate(true);
+ }
+
+ void WillOnDraw() override {
+ browser_view_renderer_->PrepareToDraw(gfx::Vector2d(), gfx::Rect());
+ browser_view_renderer_->SetContinuousInvalidate(false);
+ }
+
+ void DidOnDraw(bool success) override {
+ on_draw_count_++;
+
+ ParentCompositorDrawConstraints initialConstraint;
+ ParentCompositorDrawConstraints newConstraint =
+ ParentCompositorDrawConstraints(false, gfx::Transform(),
+ gfx::Rect(window_->surface_size()));
+ EXPECT_TRUE(success);
+ // The second onDraw will be the result of a forced invalidation because
+ // an empty global visible rect was used in the first onDraw.
+ if (on_draw_count_ == 1u) {
+ EXPECT_TRUE(
+ browser_view_renderer_->parent_draw_constraints_for_testing().Equals(
+ initialConstraint));
+ }
+
+ if (on_draw_count_ == 2u) {
+ EXPECT_TRUE(
+ browser_view_renderer_->parent_draw_constraints_for_testing().Equals(
+ newConstraint));
+ EndTest();
+ }
+ }
+
+ private:
+ size_t on_draw_count_;
+};
+
+RENDERING_TEST_F(TestForceInvalidateWithEmptyGlobalVisibleRect);
+
+class TestAnimateInAndOutOfScreen : public RenderingTest {
boliu 2015/03/13 19:14:22 I think this should replace the test above..
hush (inactive) 2015/03/13 23:24:04 Yes. Indeed.
+ public:
+ TestAnimateInAndOutOfScreen() : on_draw_count_(0u) {}
+
+ void StartTest() override {
+ browser_view_renderer_->SetContinuousInvalidate(true);
+ }
+
+ void WillOnDraw() override {
+ on_draw_count_++;
+ // First and third onDraws are onscreen.
+ // Second onDraw is offscreen.
+ if (on_draw_count_ == 2u) {
+ browser_view_renderer_->PrepareToDraw(gfx::Vector2d(), gfx::Rect());
+ browser_view_renderer_->SetContinuousInvalidate(false);
boliu 2015/03/13 19:14:22 Let's see First draw is normal, and ParentConstra
hush (inactive) 2015/03/13 23:24:04 Please the see the new patch. I added some new syn
+ }
+ }
+
+ void DidOnDraw(bool success) override {
+ ParentCompositorDrawConstraints initialConstraint;
+ ParentCompositorDrawConstraints newConstraint =
+ ParentCompositorDrawConstraints(false, gfx::Transform(),
+ gfx::Rect(window_->surface_size()));
+ EXPECT_TRUE(success);
+ if (on_draw_count_ == 1u) {
+ EXPECT_TRUE(
+ browser_view_renderer_->parent_draw_constraints_for_testing().Equals(
+ initialConstraint));
+ }
+
+ if (on_draw_count_ == 2u) {
+ EXPECT_TRUE(
+ browser_view_renderer_->parent_draw_constraints_for_testing().Equals(
+ newConstraint));
+ }
+
+ if (on_draw_count_ == 3u) {
+ EXPECT_TRUE(
+ browser_view_renderer_->parent_draw_constraints_for_testing().Equals(
+ newConstraint));
+ EndTest();
+ }
+ }
+
+ bool WillDrawOnRT(SharedRendererState* functor) override {
+ if (on_draw_count_ == 2u)
+ return false;
+
+ return true;
+ }
+
+ private:
+ size_t on_draw_count_;
+};
+
+RENDERING_TEST_F(TestAnimateInAndOutOfScreen);
+
} // namespace android_webview
« no previous file with comments | « android_webview/browser/browser_view_renderer.cc ('k') | android_webview/browser/hardware_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698