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 #include "flutter/fml/macros.h" 20 #include "gtest/gtest.h" 21 #include "third_party/skia/include/core/SkBitmap.h" 22 #include "third_party/skia/include/core/SkCanvas.h" 23 #include "txt/font_collection.h" 24 25 namespace txt { 26 27 class RenderTest : public ::testing::Test { 28 public: 29 RenderTest(); 30 31 ~RenderTest(); 32 33 SkCanvas* GetCanvas(); 34 35 bool Snapshot(); 36 37 size_t GetTestCanvasWidth() const; 38 39 size_t GetTestCanvasHeight() const; 40 41 std::shared_ptr<txt::FontCollection> GetTestFontCollection() const; 42 43 protected: 44 void SetUp() override; 45 46 void TearDown() override; 47 48 private: 49 size_t snapshots_; 50 std::unique_ptr<SkBitmap> bitmap_; 51 std::unique_ptr<SkCanvas> canvas_; 52 std::shared_ptr<txt::FontCollection> font_collection_; 53 54 std::string GetNextSnapshotName(); 55 56 FML_DISALLOW_COPY_AND_ASSIGN(RenderTest); 57 }; 58 59 } // namespace txt 60