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

Unified Diff: mojo/common/common_custom_types_unittest.cc

Issue 2013863003: Add mojom structs for base::Time, base::TimeDelta and base::TimeTicks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/common/common_custom_types.typemap ('k') | mojo/common/test_common_custom_types.mojom » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/common/common_custom_types_unittest.cc
diff --git a/mojo/common/common_custom_types_unittest.cc b/mojo/common/common_custom_types_unittest.cc
index 1d986a20db3f0508b24a9b37c7b44b175fcbb584..d0e115b50ee1d649a640dfad08a02cabf288b7db 100644
--- a/mojo/common/common_custom_types_unittest.cc
+++ b/mojo/common/common_custom_types_unittest.cc
@@ -31,6 +31,31 @@ class TestFilePathImpl : public TestFilePath {
mojo::Binding<TestFilePath> binding_;
};
+class TestTimeImpl : public TestTime {
+ public:
+ explicit TestTimeImpl(TestTimeRequest request)
+ : binding_(this, std::move(request)) {}
+
+ // TestTime implementation:
+ void BounceTime(const base::Time& in,
+ const BounceTimeCallback& callback) override {
+ callback.Run(in);
+ }
+
+ void BounceTimeDelta(const base::TimeDelta& in,
+ const BounceTimeDeltaCallback& callback) override {
+ callback.Run(in);
+ }
+
+ void BounceTimeTicks(const base::TimeTicks& in,
+ const BounceTimeTicksCallback& callback) override {
+ callback.Run(in);
+ }
+
+ private:
+ mojo::Binding<TestTime> binding_;
+};
+
class TestValueImpl : public TestValue {
public:
explicit TestValueImpl(TestValueRequest request)
@@ -81,6 +106,54 @@ TEST_F(CommonCustomTypesTest, FilePath) {
run_loop.Run();
}
+TEST_F(CommonCustomTypesTest, Time) {
+ base::RunLoop run_loop;
+
+ TestTimePtr ptr;
+ TestTimeImpl impl(GetProxy(&ptr));
+
+ base::Time t = base::Time::Now();
+
+ ptr->BounceTime(t, [&run_loop, &t](const base::Time& out) {
+ EXPECT_EQ(t, out);
+ run_loop.Quit();
+ });
+
+ run_loop.Run();
+}
+
+TEST_F(CommonCustomTypesTest, TimeDelta) {
+ base::RunLoop run_loop;
+
+ TestTimePtr ptr;
+ TestTimeImpl impl(GetProxy(&ptr));
+
+ base::TimeDelta t = base::TimeDelta::FromDays(123);
+
+ ptr->BounceTimeDelta(t, [&run_loop, &t](const base::TimeDelta& out) {
+ EXPECT_EQ(t, out);
+ run_loop.Quit();
+ });
+
+ run_loop.Run();
+}
+
+TEST_F(CommonCustomTypesTest, TimeTicks) {
+ base::RunLoop run_loop;
+
+ TestTimePtr ptr;
+ TestTimeImpl impl(GetProxy(&ptr));
+
+ base::TimeTicks t = base::TimeTicks::Now();
+
+ ptr->BounceTimeTicks(t, [&run_loop, &t](const base::TimeTicks& out) {
+ EXPECT_EQ(t, out);
+ run_loop.Quit();
+ });
+
+ run_loop.Run();
+}
+
TEST_F(CommonCustomTypesTest, Value) {
TestValuePtr ptr;
TestValueImpl impl(GetProxy(&ptr));
« no previous file with comments | « mojo/common/common_custom_types.typemap ('k') | mojo/common/test_common_custom_types.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698