| 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 "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "ui/gfx/mojo/traits_test_service.mojom.h" | 8 #include "ui/gfx/mojo/traits_test_service.mojom.h" |
| 9 #include "ui/gfx/native_widget_types.h" | 9 #include "ui/gfx/native_widget_types.h" |
| 10 #include "ui/gfx/selection_bound.h" | 10 #include "ui/gfx/selection_bound.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 const EchoTransformCallback& callback) override { | 42 const EchoTransformCallback& callback) override { |
| 43 callback.Run(t); | 43 callback.Run(t); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void EchoAcceleratedWidget( | 46 void EchoAcceleratedWidget( |
| 47 const AcceleratedWidget& t, | 47 const AcceleratedWidget& t, |
| 48 const EchoAcceleratedWidgetCallback& callback) override { | 48 const EchoAcceleratedWidgetCallback& callback) override { |
| 49 callback.Run(t); | 49 callback.Run(t); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void EchoGpuMemoryBufferHandle( |
| 53 const GpuMemoryBufferHandle& handle, |
| 54 const EchoGpuMemoryBufferHandleCallback& callback) override { |
| 55 callback.Run(handle); |
| 56 } |
| 57 |
| 52 base::MessageLoop loop_; | 58 base::MessageLoop loop_; |
| 53 mojo::BindingSet<TraitsTestService> traits_test_bindings_; | 59 mojo::BindingSet<TraitsTestService> traits_test_bindings_; |
| 54 | 60 |
| 55 DISALLOW_COPY_AND_ASSIGN(StructTraitsTest); | 61 DISALLOW_COPY_AND_ASSIGN(StructTraitsTest); |
| 56 }; | 62 }; |
| 57 | 63 |
| 58 } // namespace | 64 } // namespace |
| 59 | 65 |
| 60 TEST_F(StructTraitsTest, SelectionBound) { | 66 TEST_F(StructTraitsTest, SelectionBound) { |
| 61 const gfx::SelectionBound::Type type = gfx::SelectionBound::CENTER; | 67 const gfx::SelectionBound::Type type = gfx::SelectionBound::CENTER; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 #endif | 133 #endif |
| 128 | 134 |
| 129 TEST_F(StructTraitsTest, MAYBE_AcceleratedWidget) { | 135 TEST_F(StructTraitsTest, MAYBE_AcceleratedWidget) { |
| 130 gfx::AcceleratedWidget input(castToAcceleratedWidget(1001)); | 136 gfx::AcceleratedWidget input(castToAcceleratedWidget(1001)); |
| 131 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); | 137 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
| 132 gfx::AcceleratedWidget output; | 138 gfx::AcceleratedWidget output; |
| 133 proxy->EchoAcceleratedWidget(input, &output); | 139 proxy->EchoAcceleratedWidget(input, &output); |
| 134 EXPECT_EQ(input, output); | 140 EXPECT_EQ(input, output); |
| 135 } | 141 } |
| 136 | 142 |
| 143 TEST_F(StructTraitsTest, GpuMemoryBufferHandle) { |
| 144 const gfx::GpuMemoryBufferId kId(99); |
| 145 const uint32_t kOffset = 126; |
| 146 const int32_t kStride = 256; |
| 147 base::SharedMemory shared_memory; |
| 148 ASSERT_TRUE(shared_memory.CreateAnonymous(1024)); |
| 149 ASSERT_TRUE(shared_memory.Map(1024)); |
| 150 |
| 151 gfx::GpuMemoryBufferHandle handle; |
| 152 handle.type = gfx::SHARED_MEMORY_BUFFER; |
| 153 handle.id = kId; |
| 154 handle.handle = base::SharedMemory::DuplicateHandle(shared_memory.handle()); |
| 155 handle.offset = kOffset; |
| 156 handle.stride = kStride; |
| 157 |
| 158 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
| 159 gfx::GpuMemoryBufferHandle output; |
| 160 proxy->EchoGpuMemoryBufferHandle(handle, &output); |
| 161 EXPECT_EQ(gfx::SHARED_MEMORY_BUFFER, output.type); |
| 162 EXPECT_EQ(kId, output.id); |
| 163 EXPECT_EQ(kOffset, output.offset); |
| 164 EXPECT_EQ(kStride, output.stride); |
| 165 base::SharedMemory output_memory(output.handle, true); |
| 166 EXPECT_TRUE(output_memory.Map(1024)); |
| 167 } |
| 168 |
| 137 } // namespace gfx | 169 } // namespace gfx |
| OLD | NEW |