OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/containers/scoped_ptr_map.h" | 5 #include "base/containers/scoped_ptr_map.h" |
6 | 6 |
7 #include <functional> | 7 #include <functional> |
8 #include <map> | 8 #include <map> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
| 16 namespace base { |
16 namespace { | 17 namespace { |
17 | 18 |
18 // A ScopedDestroyer sets a Boolean to true upon destruction. | 19 // A ScopedDestroyer sets a Boolean to true upon destruction. |
19 class ScopedDestroyer { | 20 class ScopedDestroyer { |
20 public: | 21 public: |
21 ScopedDestroyer(bool* destroyed) : destroyed_(destroyed) { | 22 ScopedDestroyer(bool* destroyed) : destroyed_(destroyed) { |
22 *destroyed_ = false; | 23 *destroyed_ = false; |
23 } | 24 } |
24 | 25 |
25 ~ScopedDestroyer() { *destroyed_ = true; } | 26 ~ScopedDestroyer() { *destroyed_ = true; } |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 ScopedPtrMap<int, scoped_ptr<ScopedDestroyer>> result = callback.Run(); | 230 ScopedPtrMap<int, scoped_ptr<ScopedDestroyer>> result = callback.Run(); |
230 EXPECT_TRUE(scoped_map.empty()); | 231 EXPECT_TRUE(scoped_map.empty()); |
231 EXPECT_EQ(elem, result.find(0)->second); | 232 EXPECT_EQ(elem, result.find(0)->second); |
232 EXPECT_FALSE(destroyed); | 233 EXPECT_FALSE(destroyed); |
233 | 234 |
234 result.clear(); | 235 result.clear(); |
235 EXPECT_TRUE(destroyed); | 236 EXPECT_TRUE(destroyed); |
236 }; | 237 }; |
237 | 238 |
238 } // namespace | 239 } // namespace |
| 240 } // namespace base |
OLD | NEW |