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

Unified Diff: ui/gfx/range/mojo/range_struct_traits_unittest.cc

Issue 2531323002: Struct traits for gfx::Range and gfx::RangeF. (Closed)
Patch Set: Addressed feedback. Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/range/mojo/range_struct_traits.h ('k') | ui/gfx/range/mojo/range_traits_test_service.mojom » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/range/mojo/range_struct_traits_unittest.cc
diff --git a/ui/gfx/range/mojo/range_struct_traits_unittest.cc b/ui/gfx/range/mojo/range_struct_traits_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..70b32f3ff75f2a153be3dbe5f39fd8012047f406
--- /dev/null
+++ b/ui/gfx/range/mojo/range_struct_traits_unittest.cc
@@ -0,0 +1,65 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/message_loop/message_loop.h"
+#include "mojo/public/cpp/bindings/binding_set.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gfx/range/mojo/range_traits_test_service.mojom.h"
+
+namespace gfx {
+
+namespace {
+
+class RangeStructTraitsTest : public testing::Test,
+ public mojom::RangeTraitsTestService {
+ public:
+ RangeStructTraitsTest() {}
+
+ protected:
+ mojom::RangeTraitsTestServicePtr GetTraitsTestProxy() {
+ return traits_test_bindings_.CreateInterfacePtrAndBind(this);
+ }
+
+ private:
+ // RangeTraitsTestService:
+ void EchoRange(const Range& p, const EchoRangeCallback& callback) override {
+ callback.Run(p);
+ }
+
+ void EchoRangeF(const RangeF& p,
+ const EchoRangeFCallback& callback) override {
+ callback.Run(p);
+ }
+
+ base::MessageLoop loop_;
+ mojo::BindingSet<RangeTraitsTestService> traits_test_bindings_;
+
+ DISALLOW_COPY_AND_ASSIGN(RangeStructTraitsTest);
+};
+
+} // namespace
+
+TEST_F(RangeStructTraitsTest, Range) {
+ const uint32_t start = 1234;
+ const uint32_t end = 5678;
+ gfx::Range input(start, end);
+ mojom::RangeTraitsTestServicePtr proxy = GetTraitsTestProxy();
+ gfx::Range output;
+ proxy->EchoRange(input, &output);
+ EXPECT_EQ(start, output.start());
+ EXPECT_EQ(end, output.end());
+}
+
+TEST_F(RangeStructTraitsTest, RangeF) {
+ const float start = 1234.5f;
+ const float end = 6789.6f;
+ gfx::RangeF input(start, end);
+ mojom::RangeTraitsTestServicePtr proxy = GetTraitsTestProxy();
+ gfx::RangeF output;
+ proxy->EchoRangeF(input, &output);
+ EXPECT_EQ(start, output.start());
+ EXPECT_EQ(end, output.end());
+}
+
+} // namespace gfx
« no previous file with comments | « ui/gfx/range/mojo/range_struct_traits.h ('k') | ui/gfx/range/mojo/range_traits_test_service.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698