OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "components/sync/base/weak_handle.h" | 5 #include "components/sync/base/weak_handle.h" |
6 | 6 |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/test/scoped_task_environment.h" |
8 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
9 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
11 | 12 |
12 namespace syncer { | 13 namespace syncer { |
13 | 14 |
14 using ::testing::_; | 15 using ::testing::_; |
15 using ::testing::SaveArg; | 16 using ::testing::SaveArg; |
16 using ::testing::StrictMock; | 17 using ::testing::StrictMock; |
17 | 18 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 t.task_runner()->PostTask( | 56 t.task_runner()->PostTask( |
56 from_here, base::Bind(&WeakHandleTest::CallTest, from_here, h)); | 57 from_here, base::Bind(&WeakHandleTest::CallTest, from_here, h)); |
57 } | 58 } |
58 | 59 |
59 private: | 60 private: |
60 static void CallTest(tracked_objects::Location from_here, | 61 static void CallTest(tracked_objects::Location from_here, |
61 const WeakHandle<Base>& h) { | 62 const WeakHandle<Base>& h) { |
62 h.Call(from_here, &Base::Test); | 63 h.Call(from_here, &Base::Test); |
63 } | 64 } |
64 | 65 |
65 base::MessageLoop message_loop_; | 66 base::test::ScopedTaskEnvironment scoped_task_environment_; |
66 }; | 67 }; |
67 | 68 |
68 TEST_F(WeakHandleTest, Uninitialized) { | 69 TEST_F(WeakHandleTest, Uninitialized) { |
69 // Default. | 70 // Default. |
70 WeakHandle<int> h; | 71 WeakHandle<int> h; |
71 EXPECT_FALSE(h.IsInitialized()); | 72 EXPECT_FALSE(h.IsInitialized()); |
72 // Copy. | 73 // Copy. |
73 { | 74 { |
74 WeakHandle<int> h2(h); | 75 WeakHandle<int> h2(h); |
75 EXPECT_FALSE(h2.IsInitialized()); | 76 EXPECT_FALSE(h2.IsInitialized()); |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 EXPECT_FALSE(base_weak_handle.IsInitialized()); | 308 EXPECT_FALSE(base_weak_handle.IsInitialized()); |
308 } | 309 } |
309 | 310 |
310 TEST_F(WeakHandleTest, TypeConversionConstructorUninitializedAssignment) { | 311 TEST_F(WeakHandleTest, TypeConversionConstructorUninitializedAssignment) { |
311 WeakHandle<Base> base_weak_handle; | 312 WeakHandle<Base> base_weak_handle; |
312 base_weak_handle = WeakHandle<Derived>(); | 313 base_weak_handle = WeakHandle<Derived>(); |
313 EXPECT_FALSE(base_weak_handle.IsInitialized()); | 314 EXPECT_FALSE(base_weak_handle.IsInitialized()); |
314 } | 315 } |
315 | 316 |
316 } // namespace syncer | 317 } // namespace syncer |
OLD | NEW |