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

Side by Side Diff: ui/gfx/mojo/struct_traits_unittest.cc

Issue 2298003002: gfx: Struct traits for GpuMemoryBufferHandle. (Closed)
Patch Set: . Created 4 years, 3 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 | « ui/gfx/mojo/buffer_types_traits.cc ('k') | ui/gfx/mojo/traits_test_service.mojom » ('j') | 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 "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
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
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 #if !defined(OS_MACOSX) && !defined(OS_IOS)
166 // TODO: Add support for mach_port on mac.
167 base::SharedMemory output_memory(output.handle, true);
168 EXPECT_TRUE(output_memory.Map(1024));
169 #endif
170 }
171
137 } // namespace gfx 172 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/mojo/buffer_types_traits.cc ('k') | ui/gfx/mojo/traits_test_service.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698