1 // Copyright 2018 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "mojo/public/cpp/base/time_mojom_traits.h" 6 #include "mojo/public/cpp/test_support/test_utils.h" 7 #include "mojo/public/mojom/base/time.mojom.h" 8 #include "testing/gtest/include/gtest/gtest.h" 9 10 namespace mojo_base { 11 namespace time_unittest { 12 13 TEST(TimeTest, Time) { 14 base::Time in = base::Time::Now(); 15 base::Time out; 16 17 ASSERT_TRUE(mojo::test::SerializeAndDeserialize<mojom::Time>(&in, &out)); 18 EXPECT_EQ(in, out); 19 } 20 21 TEST(TimeTest, TimeDelta) { 22 base::TimeDelta in = base::TimeDelta::FromDays(123); 23 base::TimeDelta out; 24 25 ASSERT_TRUE(mojo::test::SerializeAndDeserialize<mojom::TimeDelta>(&in, &out)); 26 EXPECT_EQ(in, out); 27 } 28 29 TEST(TimeTest, TimeTicks) { 30 base::TimeTicks in = base::TimeTicks::Now(); 31 base::TimeTicks out; 32 33 ASSERT_TRUE(mojo::test::SerializeAndDeserialize<mojom::TimeTicks>(&in, &out)); 34 EXPECT_EQ(in, out); 35 } 36 37 } // namespace time_unittest 38 } // namespace mojo_base