| 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/display/display.h" | 8 #include "ui/display/display.h" |
| 9 #include "ui/display/display_layout.h" | 9 #include "ui/display/display_layout.h" |
| 10 #include "ui/display/mojo/display_struct_traits_test.mojom.h" | 10 #include "ui/display/mojo/display_struct_traits_test.mojom.h" |
| 11 #include "ui/display/types/display_mode.h" | 11 #include "ui/display/types/display_mode.h" |
| 12 #include "ui/display/types/gamma_ramp_rgb_entry.h" |
| 12 #include "ui/gfx/geometry/rect.h" | 13 #include "ui/gfx/geometry/rect.h" |
| 13 #include "ui/gfx/geometry/size.h" | 14 #include "ui/gfx/geometry/size.h" |
| 14 | 15 |
| 15 namespace display { | 16 namespace display { |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 constexpr int64_t kDisplayId1 = 123; | 19 constexpr int64_t kDisplayId1 = 123; |
| 19 constexpr int64_t kDisplayId2 = 456; | 20 constexpr int64_t kDisplayId2 = 456; |
| 20 constexpr int64_t kDisplayId3 = 789; | 21 constexpr int64_t kDisplayId3 = 789; |
| 21 | 22 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 45 const DisplayPlacement& in, | 46 const DisplayPlacement& in, |
| 46 const EchoDisplayPlacementCallback& callback) override { | 47 const EchoDisplayPlacementCallback& callback) override { |
| 47 callback.Run(in); | 48 callback.Run(in); |
| 48 } | 49 } |
| 49 | 50 |
| 50 void EchoDisplayLayout(std::unique_ptr<display::DisplayLayout> in, | 51 void EchoDisplayLayout(std::unique_ptr<display::DisplayLayout> in, |
| 51 const EchoDisplayLayoutCallback& callback) override { | 52 const EchoDisplayLayoutCallback& callback) override { |
| 52 callback.Run(std::move(in)); | 53 callback.Run(std::move(in)); |
| 53 } | 54 } |
| 54 | 55 |
| 56 void EchoGammaRampRGBEntry( |
| 57 const GammaRampRGBEntry& in, |
| 58 const EchoGammaRampRGBEntryCallback& callback) override { |
| 59 callback.Run(in); |
| 60 } |
| 61 |
| 55 base::MessageLoop loop_; // A MessageLoop is needed for Mojo IPC to work. | 62 base::MessageLoop loop_; // A MessageLoop is needed for Mojo IPC to work. |
| 56 mojo::BindingSet<mojom::DisplayStructTraitsTest> traits_test_bindings_; | 63 mojo::BindingSet<mojom::DisplayStructTraitsTest> traits_test_bindings_; |
| 57 | 64 |
| 58 DISALLOW_COPY_AND_ASSIGN(DisplayStructTraitsTest); | 65 DISALLOW_COPY_AND_ASSIGN(DisplayStructTraitsTest); |
| 59 }; | 66 }; |
| 60 | 67 |
| 61 void CheckDisplaysEqual(const Display& input, const Display& output) { | 68 void CheckDisplaysEqual(const Display& input, const Display& output) { |
| 62 EXPECT_NE(&input, &output); // Make sure they aren't the same object. | 69 EXPECT_NE(&input, &output); // Make sure they aren't the same object. |
| 63 EXPECT_EQ(input.id(), output.id()); | 70 EXPECT_EQ(input.id(), output.id()); |
| 64 EXPECT_EQ(input.bounds(), output.bounds()); | 71 EXPECT_EQ(input.bounds(), output.bounds()); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 input->primary_id = kDisplayId2; | 219 input->primary_id = kDisplayId2; |
| 213 input->mirrored = true; | 220 input->mirrored = true; |
| 214 input->default_unified = true; | 221 input->default_unified = true; |
| 215 | 222 |
| 216 std::unique_ptr<DisplayLayout> output; | 223 std::unique_ptr<DisplayLayout> output; |
| 217 GetTraitsTestProxy()->EchoDisplayLayout(input->Copy(), &output); | 224 GetTraitsTestProxy()->EchoDisplayLayout(input->Copy(), &output); |
| 218 | 225 |
| 219 CheckDisplayLayoutsEqual(*input, *output); | 226 CheckDisplayLayoutsEqual(*input, *output); |
| 220 } | 227 } |
| 221 | 228 |
| 229 TEST_F(DisplayStructTraitsTest, BasicGammaRampRGBEntry) { |
| 230 const GammaRampRGBEntry input{259, 81, 16}; |
| 231 |
| 232 GammaRampRGBEntry output; |
| 233 GetTraitsTestProxy()->EchoGammaRampRGBEntry(input, &output); |
| 234 |
| 235 EXPECT_EQ(input.r, output.r); |
| 236 EXPECT_EQ(input.g, output.g); |
| 237 EXPECT_EQ(input.b, output.b); |
| 238 } |
| 239 |
| 222 } // namespace display | 240 } // namespace display |
| OLD | NEW |