aw: Fix clearView implementation
[chromium-blink-merge.git] / android_webview / browser / browser_view_renderer_unittest.cc
blobb4a9d42227241cef82d61d71a47608eb57d52001
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "android_webview/browser/browser_view_renderer.h"
6 #include "android_webview/browser/test/rendering_test.h"
8 namespace android_webview {
10 class SmokeTest : public RenderingTest {
11 void StartTest() override {
12 browser_view_renderer_->SetContinuousInvalidate(true);
15 void WillOnDraw() override {
16 browser_view_renderer_->SetContinuousInvalidate(false);
19 void DidDrawOnRT(SharedRendererState* functor) override {
20 EndTest();
24 RENDERING_TEST_F(SmokeTest);
26 class ClearViewTest : public RenderingTest {
27 public:
28 ClearViewTest() : on_draw_count_(0u) {}
30 void StartTest() override {
31 browser_view_renderer_->SetContinuousInvalidate(true);
32 browser_view_renderer_->ClearView();
35 void WillOnDraw() override {
36 on_draw_count_++;
37 if (on_draw_count_ == 2u) {
38 browser_view_renderer_->SetContinuousInvalidate(false);
42 void DidOnDraw(bool success) override {
43 if (on_draw_count_ == 1u) {
44 // First OnDraw should be skipped due to ClearView.
45 EXPECT_FALSE(success);
46 browser_view_renderer_->DidUpdateContent(); // Unset ClearView.
47 } else {
48 // Following OnDraws should succeed.
49 EXPECT_TRUE(success);
53 void DidDrawOnRT(SharedRendererState* functor) override {
54 EndTest();
56 private:
57 size_t on_draw_count_;
60 RENDERING_TEST_F(ClearViewTest);
62 } // namespace android_webview