| 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 "sync/internal_api/public/util/weak_handle.h" | 5 #include "sync/internal_api/public/util/weak_handle.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 | 92 |
| 93 TEST_F(WeakHandleTest, InitializedAfterDestroy) { | 93 TEST_F(WeakHandleTest, InitializedAfterDestroy) { |
| 94 WeakHandle<Base> h; | 94 WeakHandle<Base> h; |
| 95 { | 95 { |
| 96 StrictMock<Base> b; | 96 StrictMock<Base> b; |
| 97 h = b.AsWeakHandle(); | 97 h = b.AsWeakHandle(); |
| 98 } | 98 } |
| 99 EXPECT_TRUE(h.IsInitialized()); | 99 EXPECT_TRUE(h.IsInitialized()); |
| 100 EXPECT_FALSE(h.Get()); | 100 EXPECT_FALSE(h.Get().get()); |
| 101 } | 101 } |
| 102 | 102 |
| 103 TEST_F(WeakHandleTest, InitializedAfterInvalidate) { | 103 TEST_F(WeakHandleTest, InitializedAfterInvalidate) { |
| 104 StrictMock<Base> b; | 104 StrictMock<Base> b; |
| 105 WeakHandle<Base> h = b.AsWeakHandle(); | 105 WeakHandle<Base> h = b.AsWeakHandle(); |
| 106 b.Kill(); | 106 b.Kill(); |
| 107 EXPECT_TRUE(h.IsInitialized()); | 107 EXPECT_TRUE(h.IsInitialized()); |
| 108 EXPECT_FALSE(h.Get()); | 108 EXPECT_FALSE(h.Get().get()); |
| 109 } | 109 } |
| 110 | 110 |
| 111 TEST_F(WeakHandleTest, Call) { | 111 TEST_F(WeakHandleTest, Call) { |
| 112 StrictMock<Base> b; | 112 StrictMock<Base> b; |
| 113 const char test_str[] = "test"; | 113 const char test_str[] = "test"; |
| 114 EXPECT_CALL(b, Test()); | 114 EXPECT_CALL(b, Test()); |
| 115 EXPECT_CALL(b, Test1(5)); | 115 EXPECT_CALL(b, Test1(5)); |
| 116 EXPECT_CALL(b, Test2(5, &b)); | 116 EXPECT_CALL(b, Test2(5, &b)); |
| 117 EXPECT_CALL(b, Test3(5, &b, 5)); | 117 EXPECT_CALL(b, Test3(5, &b, 5)); |
| 118 EXPECT_CALL(b, Test4(5, &b, 5, test_str)); | 118 EXPECT_CALL(b, Test4(5, &b, 5, test_str)); |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 EXPECT_FALSE(base_weak_handle.IsInitialized()); | 317 EXPECT_FALSE(base_weak_handle.IsInitialized()); |
| 318 } | 318 } |
| 319 | 319 |
| 320 TEST_F(WeakHandleTest, TypeConversionConstructorUninitializedAssignment) { | 320 TEST_F(WeakHandleTest, TypeConversionConstructorUninitializedAssignment) { |
| 321 WeakHandle<Base> base_weak_handle; | 321 WeakHandle<Base> base_weak_handle; |
| 322 base_weak_handle = WeakHandle<Derived>(); | 322 base_weak_handle = WeakHandle<Derived>(); |
| 323 EXPECT_FALSE(base_weak_handle.IsInitialized()); | 323 EXPECT_FALSE(base_weak_handle.IsInitialized()); |
| 324 } | 324 } |
| 325 | 325 |
| 326 } // namespace syncer | 326 } // namespace syncer |
| OLD | NEW |