| 1 | // Copyright 2013 The Flutter 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. |
| 4 | |
| 5 | #ifndef TESTING_CANVAS_TEST_H_ |
| 6 | #define TESTING_CANVAS_TEST_H_ |
| 7 | |
| 8 | #include "flutter/fml/macros.h" |
| 9 | #include "flutter/testing/mock_canvas.h" |
| 10 | #include "gtest/gtest.h" |
| 11 | #include "third_party/skia/include/core/SkColorSpace.h" |
| 12 | |
| 13 | namespace flutter { |
| 14 | namespace testing { |
| 15 | |
| 16 | // This fixture allows creating tests that make use of a mock |SkCanvas|. |
| 17 | template <typename BaseT> |
| 18 | class CanvasTestBase : public BaseT { |
| 19 | public: |
| 20 | CanvasTestBase() = default; |
| 21 | |
| 22 | MockCanvas& mock_canvas() { return canvas_; } |
| 23 | SkColorSpace* mock_color_space() { return color_space_.get(); } |
| 24 | |
| 25 | private: |
| 26 | MockCanvas canvas_; |
| 27 | sk_sp<SkColorSpace> color_space_ = SkColorSpace::MakeSRGB(); |
| 28 | |
| 29 | FML_DISALLOW_COPY_AND_ASSIGN(CanvasTestBase); |
| 30 | }; |
| 31 | using CanvasTest = CanvasTestBase<::testing::Test>; |
| 32 | |
| 33 | } // namespace testing |
| 34 | } // namespace flutter |
| 35 | |
| 36 | #endif // TESTING_CANVAS_TEST_H_ |
| 37 |
