| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/memory/weak_ptr.h" | 7 #include "base/memory/weak_ptr.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 { | 328 { |
| 329 Producer producer; | 329 Producer producer; |
| 330 Consumer consumer; | 330 Consumer consumer; |
| 331 consumer.producer = producer.AsWeakPtr(); | 331 consumer.producer = producer.AsWeakPtr(); |
| 332 thread.CreateConsumerFromConsumer(&consumer_copy, &consumer); | 332 thread.CreateConsumerFromConsumer(&consumer_copy, &consumer); |
| 333 } | 333 } |
| 334 EXPECT_TRUE(consumer_copy->producer == NULL); | 334 EXPECT_TRUE(consumer_copy->producer == NULL); |
| 335 thread.DeleteConsumer(consumer_copy); | 335 thread.DeleteConsumer(consumer_copy); |
| 336 } | 336 } |
| 337 | 337 |
| 338 TEST(WeakPtrTest, Dereference) { |
| 339 Base data; |
| 340 WeakPtrFactory<Base> factory(&data); |
| 341 WeakPtr<Base> ptr = factory.GetWeakPtr(); |
| 342 EXPECT_EQ(&data, ptr.get()); |
| 343 EXPECT_EQ(&data, *ptr); |
| 344 } |
| 345 |
| 338 } // namespace base | 346 } // namespace base |
| OLD | NEW |