Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(339)

Side by Side Diff: base/observer_list_unittest.cc

Issue 369001: Improve the run time of base_unittests by about 20s by reducing timeouts in (Closed)
Patch Set: Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | base/thread_collision_warner_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 bool added; 77 bool added;
78 ObserverList<Foo>* observer_list; 78 ObserverList<Foo>* observer_list;
79 Adder adder; 79 Adder adder;
80 }; 80 };
81 81
82 82
83 class ObserverListThreadSafeTest : public testing::Test { 83 class ObserverListThreadSafeTest : public testing::Test {
84 }; 84 };
85 85
86 static const int kThreadRunTime = 10000; // ms to run the multi-threaded test. 86 static const int kThreadRunTime = 2000; // ms to run the multi-threaded test.
87 87
88 // A thread for use in the ThreadSafeObserver test 88 // A thread for use in the ThreadSafeObserver test
89 // which will add and remove itself from the notification 89 // which will add and remove itself from the notification
90 // list repeatedly. 90 // list repeatedly.
91 class AddRemoveThread : public PlatformThread::Delegate, 91 class AddRemoveThread : public PlatformThread::Delegate,
92 public Foo { 92 public Foo {
93 public: 93 public:
94 AddRemoveThread(ObserverListThreadSafe<Foo>* list, bool notify) 94 AddRemoveThread(ObserverListThreadSafe<Foo>* list, bool notify)
95 : list_(list), 95 : list_(list),
96 in_list_(false), 96 in_list_(false),
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 297
298 EXPECT_TRUE(b.added); 298 EXPECT_TRUE(b.added);
299 // B's adder should not have been notified because it was added during 299 // B's adder should not have been notified because it was added during
300 // notificaiton. 300 // notificaiton.
301 EXPECT_EQ(0, b.adder.total); 301 EXPECT_EQ(0, b.adder.total);
302 302
303 // Notify again to make sure b's adder is notified. 303 // Notify again to make sure b's adder is notified.
304 FOR_EACH_OBSERVER(Foo, observer_list, Observe(1)); 304 FOR_EACH_OBSERVER(Foo, observer_list, Observe(1));
305 EXPECT_EQ(1, b.adder.total); 305 EXPECT_EQ(1, b.adder.total);
306 } 306 }
OLDNEW
« no previous file with comments | « no previous file | base/thread_collision_warner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698