OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "base/observer_list.h" | 6 #include "base/observer_list.h" |
7 #include "base/observer_list_threadsafe.h" | 7 #include "base/observer_list_threadsafe.h" |
8 #include "base/platform_thread.h" | 8 #include "base/platform_thread.h" |
9 #include "base/ref_counted.h" | 9 #include "base/ref_counted.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
| 12 using base::Time; |
| 13 |
12 namespace { | 14 namespace { |
13 | 15 |
14 class ObserverListTest : public testing::Test { | 16 class ObserverListTest : public testing::Test { |
15 }; | 17 }; |
16 | 18 |
17 class Foo { | 19 class Foo { |
18 public: | 20 public: |
19 virtual void Observe(int x) = 0; | 21 virtual void Observe(int x) = 0; |
20 virtual ~Foo() {} | 22 virtual ~Foo() {} |
21 }; | 23 }; |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 // Use 7 observer threads. Notifications only come from | 255 // Use 7 observer threads. Notifications only come from |
254 // the main thread. | 256 // the main thread. |
255 ThreadSafeObserverHarness(7, false); | 257 ThreadSafeObserverHarness(7, false); |
256 } | 258 } |
257 | 259 |
258 TEST(ObserverListThreadSafeTest, CrossThreadNotifications) { | 260 TEST(ObserverListThreadSafeTest, CrossThreadNotifications) { |
259 // Use 3 observer threads. Notifications will fire from | 261 // Use 3 observer threads. Notifications will fire from |
260 // the main thread and all 3 observer threads. | 262 // the main thread and all 3 observer threads. |
261 ThreadSafeObserverHarness(3, true); | 263 ThreadSafeObserverHarness(3, true); |
262 } | 264 } |
OLD | NEW |