Skip to content

Commit

Permalink
Add flow test fixtures and tests (flutter#13986)
Browse files Browse the repository at this point in the history
  • Loading branch information
arbreng authored and fluttergithubbot committed Dec 3, 2019
1 parent fffeb8f commit 620f528
Show file tree
Hide file tree
Showing 85 changed files with 4,524 additions and 388 deletions.
5 changes: 4 additions & 1 deletion BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ group("flutter") {

# Fuchsia currently only supports a subset of our unit tests
if (is_fuchsia) {
public_deps += [ "$flutter_root/fml:fml_tests" ]
public_deps += [
"$flutter_root/flow:flow_tests",
"$flutter_root/fml:fml_tests",
]
}
}

Expand Down
13 changes: 13 additions & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,33 @@ FILE: ../../../flutter/flow/instrumentation.cc
FILE: ../../../flutter/flow/instrumentation.h
FILE: ../../../flutter/flow/layers/backdrop_filter_layer.cc
FILE: ../../../flutter/flow/layers/backdrop_filter_layer.h
FILE: ../../../flutter/flow/layers/backdrop_filter_layer_unittests.cc
FILE: ../../../flutter/flow/layers/child_scene_layer.cc
FILE: ../../../flutter/flow/layers/child_scene_layer.h
FILE: ../../../flutter/flow/layers/clip_path_layer.cc
FILE: ../../../flutter/flow/layers/clip_path_layer.h
FILE: ../../../flutter/flow/layers/clip_path_layer_unittests.cc
FILE: ../../../flutter/flow/layers/clip_rect_layer.cc
FILE: ../../../flutter/flow/layers/clip_rect_layer.h
FILE: ../../../flutter/flow/layers/clip_rect_layer_unittests.cc
FILE: ../../../flutter/flow/layers/clip_rrect_layer.cc
FILE: ../../../flutter/flow/layers/clip_rrect_layer.h
FILE: ../../../flutter/flow/layers/clip_rrect_layer_unittests.cc
FILE: ../../../flutter/flow/layers/color_filter_layer.cc
FILE: ../../../flutter/flow/layers/color_filter_layer.h
FILE: ../../../flutter/flow/layers/color_filter_layer_unittests.cc
FILE: ../../../flutter/flow/layers/container_layer.cc
FILE: ../../../flutter/flow/layers/container_layer.h
FILE: ../../../flutter/flow/layers/container_layer_unittests.cc
FILE: ../../../flutter/flow/layers/layer.cc
FILE: ../../../flutter/flow/layers/layer.h
FILE: ../../../flutter/flow/layers/layer_tree.cc
FILE: ../../../flutter/flow/layers/layer_tree.h
FILE: ../../../flutter/flow/layers/layer_tree_unittests.cc
FILE: ../../../flutter/flow/layers/layer_unittests.cc
FILE: ../../../flutter/flow/layers/opacity_layer.cc
FILE: ../../../flutter/flow/layers/opacity_layer.h
FILE: ../../../flutter/flow/layers/opacity_layer_unittests.cc
FILE: ../../../flutter/flow/layers/performance_overlay_layer.cc
FILE: ../../../flutter/flow/layers/performance_overlay_layer.h
FILE: ../../../flutter/flow/layers/performance_overlay_layer_unittests.cc
Expand All @@ -57,14 +65,19 @@ FILE: ../../../flutter/flow/layers/physical_shape_layer.h
FILE: ../../../flutter/flow/layers/physical_shape_layer_unittests.cc
FILE: ../../../flutter/flow/layers/picture_layer.cc
FILE: ../../../flutter/flow/layers/picture_layer.h
FILE: ../../../flutter/flow/layers/picture_layer_unittests.cc
FILE: ../../../flutter/flow/layers/platform_view_layer.cc
FILE: ../../../flutter/flow/layers/platform_view_layer.h
FILE: ../../../flutter/flow/layers/platform_view_layer_unittests.cc
FILE: ../../../flutter/flow/layers/shader_mask_layer.cc
FILE: ../../../flutter/flow/layers/shader_mask_layer.h
FILE: ../../../flutter/flow/layers/shader_mask_layer_unittests.cc
FILE: ../../../flutter/flow/layers/texture_layer.cc
FILE: ../../../flutter/flow/layers/texture_layer.h
FILE: ../../../flutter/flow/layers/texture_layer_unittests.cc
FILE: ../../../flutter/flow/layers/transform_layer.cc
FILE: ../../../flutter/flow/layers/transform_layer.h
FILE: ../../../flutter/flow/layers/transform_layer_unittests.cc
FILE: ../../../flutter/flow/matrix_decomposition.cc
FILE: ../../../flutter/flow/matrix_decomposition.h
FILE: ../../../flutter/flow/matrix_decomposition_unittests.cc
Expand Down
74 changes: 73 additions & 1 deletion flow/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

if (is_fuchsia) {
import("//build/fuchsia/sdk.gni")
import("$flutter_root/tools/fuchsia/fuchsia_archive.gni")
}

import("$flutter_root/testing/testing.gni")

source_set("flow") {
Expand Down Expand Up @@ -102,30 +102,102 @@ test_fixtures("flow_fixtures") {
fixtures = []
}

source_set("flow_testing") {
testonly = true

sources = [
"testing/layer_test.h",
"testing/mock_layer.cc",
"testing/mock_layer.h",
"testing/mock_texture.cc",
"testing/mock_texture.h",
"testing/skia_gpu_object_layer_test.cc",
"testing/skia_gpu_object_layer_test.h",
]

public_deps = [
":flow",
"$flutter_root/testing:skia",
"//third_party/googletest:gtest",
]
}

executable("flow_unittests") {
testonly = true

sources = [
"flow_run_all_unittests.cc",
"flow_test_utils.cc",
"flow_test_utils.h",
"layers/backdrop_filter_layer_unittests.cc",
"layers/clip_path_layer_unittests.cc",
"layers/clip_rect_layer_unittests.cc",
"layers/clip_rrect_layer_unittests.cc",
"layers/color_filter_layer_unittests.cc",
"layers/container_layer_unittests.cc",
"layers/layer_tree_unittests.cc",
"layers/layer_unittests.cc",
"layers/opacity_layer_unittests.cc",
"layers/performance_overlay_layer_unittests.cc",
"layers/physical_shape_layer_unittests.cc",
"layers/picture_layer_unittests.cc",
"layers/platform_view_layer_unittests.cc",
"layers/shader_mask_layer_unittests.cc",
"layers/texture_layer_unittests.cc",
"layers/transform_layer_unittests.cc",
"matrix_decomposition_unittests.cc",
"mutators_stack_unittests.cc",
"raster_cache_unittests.cc",
"skia_gpu_object_unittests.cc",
"testing/mock_layer_unittests.cc",
"testing/mock_texture_unittests.cc",
"texture_unittests.cc",
]

deps = [
":flow",
":flow_fixtures",
":flow_testing",
"$flutter_root/fml",
"$flutter_root/testing:skia",
"$flutter_root/testing:testing_lib",
"//third_party/dart/runtime:libdart_jit", # for tracing
"//third_party/googletest:gtest",
"//third_party/skia",
]
}

if (is_fuchsia) {
fuchsia_archive("flow_tests") {
testonly = true

deps = [
":flow_unittests",
]

binary = "flow_unittests"

libraries = common_libs

meta_dir = "$flutter_root/testing/fuchsia/meta"
cmx_file = "$meta_dir/fuchsia_test.cmx"

resources = [
{
path = rebase_path(
"$flutter_root/testing/resources/performance_overlay_gold_60fps.png")
dest = "flutter/testing/resources/performance_overlay_gold_60fps.png"
},
{
path = rebase_path(
"$flutter_root/testing/resources/performance_overlay_gold_90fps.png")
dest = "flutter/testing/resources/performance_overlay_gold_90fps.png"
},
{
path = rebase_path(
"$flutter_root/testing/resources/performance_overlay_gold_120fps.png")
dest = "flutter/testing/resources/performance_overlay_gold_120fps.png"
},
]
}
}
17 changes: 17 additions & 0 deletions flow/embedded_views.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class MutatorsStack {
// Returns an iterator pointing to the bottom of the stack.
const std::vector<std::shared_ptr<Mutator>>::const_reverse_iterator Bottom()
const;
bool is_empty() const { return vector_.empty(); }

bool operator==(const MutatorsStack& other) const {
if (vector_.size() != other.vector_.size()) {
Expand All @@ -156,10 +157,26 @@ class MutatorsStack {
return true;
}

bool operator==(const std::vector<Mutator>& other) const {
if (vector_.size() != other.size()) {
return false;
}
for (size_t i = 0; i < vector_.size(); i++) {
if (*vector_[i] != other[i]) {
return false;
}
}
return true;
}

bool operator!=(const MutatorsStack& other) const {
return !operator==(other);
}

bool operator!=(const std::vector<Mutator>& other) const {
return !operator==(other);
}

private:
std::vector<std::shared_ptr<Mutator>> vector_;
}; // MutatorsStack
Expand Down
7 changes: 7 additions & 0 deletions flow/flow_run_all_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

#include "flutter/fml/build_config.h"
#include "flutter/fml/command_line.h"
#include "flutter/fml/logging.h"
#include "gtest/gtest.h"
Expand All @@ -23,8 +24,14 @@
int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
fml::CommandLine cmd = fml::CommandLineFromArgcArgv(argc, argv);

#if defined(OS_FUCHSIA)
flutter::SetGoldenDir(cmd.GetOptionValueWithDefault(
"golden-dir", "/pkg/data/flutter/testing/resources"));
#else
flutter::SetGoldenDir(
cmd.GetOptionValueWithDefault("golden-dir", "flutter/testing/resources"));
#endif
flutter::SetFontFile(cmd.GetOptionValueWithDefault(
"font-file",
"flutter/third_party/txt/third_party/fonts/Roboto-Regular.ttf"));
Expand Down
2 changes: 0 additions & 2 deletions flow/layers/backdrop_filter_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ BackdropFilterLayer::BackdropFilterLayer(sk_sp<SkImageFilter> filter)
set_layer_reads_surface(filter_.get() != nullptr);
}

BackdropFilterLayer::~BackdropFilterLayer() = default;

void BackdropFilterLayer::Paint(PaintContext& context) const {
TRACE_EVENT0("flutter", "BackdropFilterLayer::Paint");
FML_DCHECK(needs_painting());
Expand Down
1 change: 0 additions & 1 deletion flow/layers/backdrop_filter_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ namespace flutter {
class BackdropFilterLayer : public ContainerLayer {
public:
BackdropFilterLayer(sk_sp<SkImageFilter> filter);
~BackdropFilterLayer() override;

void Paint(PaintContext& context) const override;

Expand Down
Loading

0 comments on commit 620f528

Please sign in to comment.