Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(409)

Side by Side Diff: skia/public/interfaces/test/struct_traits_unittest.cc

Issue 2042413003: Implement cc::FilterOperation StructTraits (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased + Addressed Enne's comment Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « skia/public/interfaces/image_filter_struct_traits.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/message_loop/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 #include "mojo/public/cpp/bindings/binding_set.h" 6 #include "mojo/public/cpp/bindings/binding_set.h"
7 #include "skia/public/interfaces/test/traits_test_service.mojom.h" 7 #include "skia/public/interfaces/test/traits_test_service.mojom.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "third_party/skia/include/core/SkColorFilter.h" 9 #include "third_party/skia/include/core/SkColorFilter.h"
10 #include "third_party/skia/include/core/SkString.h" 10 #include "third_party/skia/include/core/SkString.h"
11 #include "third_party/skia/include/effects/SkColorFilterImageFilter.h" 11 #include "third_party/skia/include/effects/SkColorFilterImageFilter.h"
12 #include "third_party/skia/include/effects/SkDropShadowImageFilter.h"
12 #include "ui/gfx/skia_util.h" 13 #include "ui/gfx/skia_util.h"
13 14
14 namespace skia { 15 namespace skia {
15 16
16 namespace { 17 namespace {
17 18
18 class StructTraitsTest : public testing::Test, public mojom::TraitsTestService { 19 class StructTraitsTest : public testing::Test, public mojom::TraitsTestService {
19 public: 20 public:
20 StructTraitsTest() {} 21 StructTraitsTest() {}
21 22
22 protected: 23 protected:
23 mojom::TraitsTestServicePtr GetTraitsTestProxy() { 24 mojom::TraitsTestServicePtr GetTraitsTestProxy() {
24 return traits_test_bindings_.CreateInterfacePtrAndBind(this); 25 return traits_test_bindings_.CreateInterfacePtrAndBind(this);
25 } 26 }
26 27
27 private: 28 private:
28 // TraitsTestService: 29 // TraitsTestService:
29 void EchoBitmap(const SkBitmap& b, 30 void EchoBitmap(const SkBitmap& b,
30 const EchoBitmapCallback& callback) override { 31 const EchoBitmapCallback& callback) override {
31 callback.Run(b); 32 callback.Run(b);
32 } 33 }
34
33 void EchoImageFilter(const sk_sp<SkImageFilter>& i, 35 void EchoImageFilter(const sk_sp<SkImageFilter>& i,
34 const EchoImageFilterCallback& callback) override { 36 const EchoImageFilterCallback& callback) override {
35 callback.Run(i); 37 callback.Run(i);
36 } 38 }
37 39
38 base::MessageLoop loop_; 40 base::MessageLoop loop_;
39 mojo::BindingSet<TraitsTestService> traits_test_bindings_; 41 mojo::BindingSet<TraitsTestService> traits_test_bindings_;
40 42
41 DISALLOW_COPY_AND_ASSIGN(StructTraitsTest); 43 DISALLOW_COPY_AND_ASSIGN(StructTraitsTest);
42 }; 44 };
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 SkString input_str; 76 SkString input_str;
75 input->toString(&input_str); 77 input->toString(&input_str);
76 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); 78 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
77 sk_sp<SkImageFilter> output; 79 sk_sp<SkImageFilter> output;
78 proxy->EchoImageFilter(input, &output); 80 proxy->EchoImageFilter(input, &output);
79 SkString output_str; 81 SkString output_str;
80 output->toString(&output_str); 82 output->toString(&output_str);
81 EXPECT_EQ(input_str, output_str); 83 EXPECT_EQ(input_str, output_str);
82 } 84 }
83 85
86 TEST_F(StructTraitsTest, DropShadowImageFilter) {
87 sk_sp<SkImageFilter> input(SkDropShadowImageFilter::Make(
88 SkIntToScalar(3), SkIntToScalar(8), SkIntToScalar(4), SkIntToScalar(9),
89 SK_ColorBLACK,
90 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode, nullptr));
91 SkString input_str;
92 input->toString(&input_str);
93 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
94 sk_sp<SkImageFilter> output;
95 proxy->EchoImageFilter(input, &output);
96 SkString output_str;
97 output->toString(&output_str);
98 EXPECT_EQ(input_str, output_str);
99 }
100
84 } // namespace skia 101 } // namespace skia
OLDNEW
« no previous file with comments | « skia/public/interfaces/image_filter_struct_traits.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698