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

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

Issue 2096763005: Provide StructTraits for a vector<SkBitmap> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 4 years, 5 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
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"
(...skipping 14 matching lines...) Expand all
25 return traits_test_bindings_.CreateInterfacePtrAndBind(this); 25 return traits_test_bindings_.CreateInterfacePtrAndBind(this);
26 } 26 }
27 27
28 private: 28 private:
29 // TraitsTestService: 29 // TraitsTestService:
30 void EchoBitmap(const SkBitmap& b, 30 void EchoBitmap(const SkBitmap& b,
31 const EchoBitmapCallback& callback) override { 31 const EchoBitmapCallback& callback) override {
32 callback.Run(b); 32 callback.Run(b);
33 } 33 }
34 34
35 void EchoBitmapArray(const std::vector<SkBitmap>& t,
36 const EchoBitmapArrayCallback& callback) override {
37 callback.Run(t);
38 }
39
35 void EchoImageFilter(const sk_sp<SkImageFilter>& i, 40 void EchoImageFilter(const sk_sp<SkImageFilter>& i,
36 const EchoImageFilterCallback& callback) override { 41 const EchoImageFilterCallback& callback) override {
37 callback.Run(i); 42 callback.Run(i);
38 } 43 }
39 44
40 base::MessageLoop loop_; 45 base::MessageLoop loop_;
41 mojo::BindingSet<TraitsTestService> traits_test_bindings_; 46 mojo::BindingSet<TraitsTestService> traits_test_bindings_;
42 47
43 DISALLOW_COPY_AND_ASSIGN(StructTraitsTest); 48 DISALLOW_COPY_AND_ASSIGN(StructTraitsTest);
44 }; 49 };
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 SkString input_str; 101 SkString input_str;
97 input->toString(&input_str); 102 input->toString(&input_str);
98 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); 103 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
99 sk_sp<SkImageFilter> output; 104 sk_sp<SkImageFilter> output;
100 proxy->EchoImageFilter(input, &output); 105 proxy->EchoImageFilter(input, &output);
101 SkString output_str; 106 SkString output_str;
102 output->toString(&output_str); 107 output->toString(&output_str);
103 EXPECT_EQ(input_str, output_str); 108 EXPECT_EQ(input_str, output_str);
104 } 109 }
105 110
111 TEST_F(StructTraitsTest, BitmapArray) {
112 SkBitmap b1, b2;
113
114 SkImageInfo image_info1 = SkImageInfo::MakeN32(10, 5, kPremul_SkAlphaType);
115 b1.allocPixels(image_info1);
116
117 SkImageInfo image_info2 = SkImageInfo::MakeN32(11, 6, kPremul_SkAlphaType);
118 b2.allocPixels(image_info2);
119
120 std::vector<SkBitmap> vi;
121 vi.push_back(b1);
122 vi.push_back(b2);
123
124 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
125 std::vector<SkBitmap> vo;
126 proxy->EchoBitmapArray(vi, &vo);
127
128 EXPECT_EQ(vi.size(), vo.size());
129 for (size_t i = 0; i < vi.size(); i++) {
130 EXPECT_EQ(vi[i].width(), vo[i].width());
131 EXPECT_EQ(vi[i].height(), vo[i].height());
132 }
133 }
134
106 } // namespace skia 135 } // namespace skia
OLDNEW
« no previous file with comments | « skia/public/interfaces/test/OWNERS ('k') | skia/public/interfaces/test/traits_test_service.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698