summaryrefslogtreecommitdiffstats
path: root/android_webview/browser/browser_view_renderer_unittest.cc
blob: b4a9d42227241cef82d61d71a47608eb57d52001 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "android_webview/browser/browser_view_renderer.h"
#include "android_webview/browser/test/rendering_test.h"

namespace android_webview {

class SmokeTest : public RenderingTest {
  void StartTest() override {
    browser_view_renderer_->SetContinuousInvalidate(true);
  }

  void WillOnDraw() override {
    browser_view_renderer_->SetContinuousInvalidate(false);
  }

  void DidDrawOnRT(SharedRendererState* functor) override {
    EndTest();
  }
};

RENDERING_TEST_F(SmokeTest);

class ClearViewTest : public RenderingTest {
 public:
  ClearViewTest() : on_draw_count_(0u) {}

  void StartTest() override {
    browser_view_renderer_->SetContinuousInvalidate(true);
    browser_view_renderer_->ClearView();
  }

  void WillOnDraw() override {
    on_draw_count_++;
    if (on_draw_count_ == 2u) {
      browser_view_renderer_->SetContinuousInvalidate(false);
    }
  }

  void DidOnDraw(bool success) override {
    if (on_draw_count_ == 1u) {
      // First OnDraw should be skipped due to ClearView.
      EXPECT_FALSE(success);
      browser_view_renderer_->DidUpdateContent();  // Unset ClearView.
    } else {
      // Following OnDraws should succeed.
      EXPECT_TRUE(success);
    }
  }

  void DidDrawOnRT(SharedRendererState* functor) override {
    EndTest();
  }
 private:
  size_t on_draw_count_;
};

RENDERING_TEST_F(ClearViewTest);

}  // namespace android_webview