Flutter Engine
render_test.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017 Google, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <memory>
18 #include <string>
19 
20 #include "flutter/fml/macros.h"
21 #include "gtest/gtest.h"
22 #include "third_party/skia/include/core/SkBitmap.h"
23 #include "third_party/skia/include/core/SkCanvas.h"
24 #include "txt/font_collection.h"
25 
26 namespace txt {
27 
28 class RenderTest : public ::testing::Test {
29  public:
30  RenderTest();
31 
32  ~RenderTest();
33 
34  SkCanvas* GetCanvas();
35 
36  bool Snapshot();
37 
38  size_t GetTestCanvasWidth() const;
39 
40  size_t GetTestCanvasHeight() const;
41 
42  std::shared_ptr<txt::FontCollection> GetTestFontCollection() const;
43 
44  protected:
45  void SetUp() override;
46 
47  void TearDown() override;
48 
49  private:
50  size_t snapshots_;
51  std::unique_ptr<SkBitmap> bitmap_;
52  std::unique_ptr<SkCanvas> canvas_;
53  std::shared_ptr<txt::FontCollection> font_collection_;
54 
55  std::string GetNextSnapshotName();
56 
57  FML_DISALLOW_COPY_AND_ASSIGN(RenderTest);
58 };
59 
60 } // namespace txt
size_t GetTestCanvasHeight() const
Definition: render_test.cc:80
size_t GetTestCanvasWidth() const
Definition: render_test.cc:76
SkCanvas * GetCanvas()
Definition: render_test.cc:35
void TearDown() override
Definition: render_test.cc:95
std::shared_ptr< txt::FontCollection > GetTestFontCollection() const
Definition: render_test.cc:91
void SetUp() override
Definition: render_test.cc:84