| OLD | NEW |
| 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/SkImageInfo.h" | 10 #include "third_party/skia/include/core/SkImageInfo.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 return traits_test_bindings_.CreateInterfacePtrAndBind(this); | 26 return traits_test_bindings_.CreateInterfacePtrAndBind(this); |
| 27 } | 27 } |
| 28 | 28 |
| 29 private: | 29 private: |
| 30 // TraitsTestService: | 30 // TraitsTestService: |
| 31 void EchoBitmap(const SkBitmap& b, | 31 void EchoBitmap(const SkBitmap& b, |
| 32 const EchoBitmapCallback& callback) override { | 32 const EchoBitmapCallback& callback) override { |
| 33 callback.Run(b); | 33 callback.Run(b); |
| 34 } | 34 } |
| 35 | 35 |
| 36 void EchoBitmapArray(const std::vector<SkBitmap>& t, | |
| 37 const EchoBitmapArrayCallback& callback) override { | |
| 38 callback.Run(t); | |
| 39 } | |
| 40 | |
| 41 void EchoImageFilter(const sk_sp<SkImageFilter>& i, | 36 void EchoImageFilter(const sk_sp<SkImageFilter>& i, |
| 42 const EchoImageFilterCallback& callback) override { | 37 const EchoImageFilterCallback& callback) override { |
| 43 callback.Run(i); | 38 callback.Run(i); |
| 44 } | 39 } |
| 45 | 40 |
| 46 base::MessageLoop loop_; | 41 base::MessageLoop loop_; |
| 47 mojo::BindingSet<TraitsTestService> traits_test_bindings_; | 42 mojo::BindingSet<TraitsTestService> traits_test_bindings_; |
| 48 | 43 |
| 49 DISALLOW_COPY_AND_ASSIGN(StructTraitsTest); | 44 DISALLOW_COPY_AND_ASSIGN(StructTraitsTest); |
| 50 }; | 45 }; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 SkString input_str; | 118 SkString input_str; |
| 124 input->toString(&input_str); | 119 input->toString(&input_str); |
| 125 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); | 120 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
| 126 sk_sp<SkImageFilter> output; | 121 sk_sp<SkImageFilter> output; |
| 127 proxy->EchoImageFilter(input, &output); | 122 proxy->EchoImageFilter(input, &output); |
| 128 SkString output_str; | 123 SkString output_str; |
| 129 output->toString(&output_str); | 124 output->toString(&output_str); |
| 130 EXPECT_EQ(input_str, output_str); | 125 EXPECT_EQ(input_str, output_str); |
| 131 } | 126 } |
| 132 | 127 |
| 133 TEST_F(StructTraitsTest, BitmapArray) { | |
| 134 SkBitmap b1, b2; | |
| 135 | |
| 136 SkImageInfo image_info1 = SkImageInfo::MakeN32(10, 5, kPremul_SkAlphaType); | |
| 137 b1.allocPixels(image_info1); | |
| 138 | |
| 139 SkImageInfo image_info2 = SkImageInfo::MakeN32(11, 6, kPremul_SkAlphaType); | |
| 140 b2.allocPixels(image_info2); | |
| 141 | |
| 142 std::vector<SkBitmap> vi; | |
| 143 vi.push_back(b1); | |
| 144 vi.push_back(b2); | |
| 145 | |
| 146 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); | |
| 147 std::vector<SkBitmap> vo; | |
| 148 proxy->EchoBitmapArray(vi, &vo); | |
| 149 | |
| 150 EXPECT_EQ(vi.size(), vo.size()); | |
| 151 for (size_t i = 0; i < vi.size(); i++) { | |
| 152 EXPECT_EQ(vi[i].width(), vo[i].width()); | |
| 153 EXPECT_EQ(vi[i].height(), vo[i].height()); | |
| 154 } | |
| 155 } | |
| 156 | |
| 157 } // namespace skia | 128 } // namespace skia |
| OLD | NEW |