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

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

Issue 2040233002: Implement sk_sp<SkImageFilter> StructTraits (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't build StructTraitsTest on iOS 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/message_loop/message_loop.h"
6 #include "mojo/public/cpp/bindings/binding_set.h"
7 #include "skia/public/interfaces/test/traits_test_service.mojom.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "third_party/skia/include/core/SkColorFilter.h"
10 #include "third_party/skia/include/core/SkString.h"
11 #include "third_party/skia/include/effects/SkColorFilterImageFilter.h"
12
13 namespace skia {
14
15 namespace {
16
17 class StructTraitsTest : public testing::Test, public mojom::TraitsTestService {
18 public:
19 StructTraitsTest() {}
20
21 protected:
22 mojom::TraitsTestServicePtr GetTraitsTestProxy() {
23 return traits_test_bindings_.CreateInterfacePtrAndBind(this);
24 }
25
26 private:
27 // TraitsTestService:
28 void EchoImageFilter(const sk_sp<SkImageFilter>& i,
29 const EchoImageFilterCallback& callback) override {
30 callback.Run(i);
31 }
32
33 base::MessageLoop loop_;
34 mojo::BindingSet<TraitsTestService> traits_test_bindings_;
35
36 DISALLOW_COPY_AND_ASSIGN(StructTraitsTest);
37 };
38
39 static sk_sp<SkImageFilter> make_scale(float amount,
40 sk_sp<SkImageFilter> input) {
41 SkScalar s = amount;
42 SkScalar matrix[20] = {s, 0, 0, 0, 0, 0, s, 0, 0, 0,
43 0, 0, s, 0, 0, 0, 0, 0, s, 0};
44 sk_sp<SkColorFilter> filter(
45 SkColorFilter::MakeMatrixFilterRowMajor255(matrix));
46 return SkColorFilterImageFilter::Make(std::move(filter), std::move(input));
47 }
48
49 } // namespace
50
51 TEST_F(StructTraitsTest, ImageFilter) {
52 sk_sp<SkImageFilter> input(make_scale(0.5f, nullptr));
53 SkString input_str;
54 input->toString(&input_str);
55 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
56 sk_sp<SkImageFilter> output;
57 proxy->EchoImageFilter(input, &output);
58 SkString output_str;
59 output->toString(&output_str);
60 EXPECT_EQ(input_str, output_str);
61 }
62
63 } // namespace skia
OLDNEW
« no previous file with comments | « skia/public/interfaces/image_filter_struct_traits.cc ('k') | skia/public/interfaces/test/traits_test_service.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698