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

Side by Side Diff: Source/platform/LifecycleContextTest.cpp

Issue 1182703002: Fix unit test style in Source/platform/, part 1. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 months 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All Rights Reserved. 2 * Copyright (C) 2013 Google Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 11 matching lines...) Expand all
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 * 24 *
25 */ 25 */
26 26
27 #include "config.h" 27 #include "config.h"
28 28
29 #include "platform/LifecycleNotifier.h" 29 #include "platform/LifecycleNotifier.h"
30 #include "platform/LifecycleObserver.h" 30 #include "platform/LifecycleObserver.h"
31 #include "platform/heap/Handle.h" 31 #include "platform/heap/Handle.h"
32
33 #include <gtest/gtest.h> 32 #include <gtest/gtest.h>
34 33
35 using namespace blink;
36
37 namespace blink { 34 namespace blink {
38 35
39 class TestingObserver; 36 class TestingObserver;
40 37
41 class DummyContext final : public NoBaseWillBeGarbageCollectedFinalized<DummyCon text>, public LifecycleNotifier<DummyContext, TestingObserver> { 38 class DummyContext final : public NoBaseWillBeGarbageCollectedFinalized<DummyCon text>, public LifecycleNotifier<DummyContext, TestingObserver> {
42 public: 39 public:
43 static PassOwnPtrWillBeRawPtr<DummyContext> create() 40 static PassOwnPtrWillBeRawPtr<DummyContext> create()
44 { 41 {
45 return adoptPtrWillBeNoop(new DummyContext()); 42 return adoptPtrWillBeNoop(new DummyContext());
46 } 43 }
47 44
48 DEFINE_INLINE_TRACE() 45 DEFINE_INLINE_TRACE()
49 { 46 {
50 LifecycleNotifier<DummyContext, TestingObserver>::trace(visitor); 47 LifecycleNotifier<DummyContext, TestingObserver>::trace(visitor);
51 } 48 }
52 }; 49 };
53 50
54 class TestingObserver final : public NoBaseWillBeGarbageCollectedFinalized<Testi ngObserver>, public LifecycleObserver<DummyContext, TestingObserver, DummyContex t> { 51 class TestingObserver final : public NoBaseWillBeGarbageCollectedFinalized<Testi ngObserver>, public LifecycleObserver<DummyContext, TestingObserver, DummyContex t> {
55 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(TestingObserver); 52 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(TestingObserver);
56 public: 53 public:
57 static PassOwnPtrWillBeRawPtr<TestingObserver> create(DummyContext* context) 54 static PassOwnPtrWillBeRawPtr<TestingObserver> create(DummyContext* context)
58 { 55 {
59 return adoptPtrWillBeNoop(new TestingObserver(context)); 56 return adoptPtrWillBeNoop(new TestingObserver(context));
60 } 57 }
61 58
62 virtual void contextDestroyed() override 59 void contextDestroyed() override
63 { 60 {
64 LifecycleObserver::contextDestroyed(); 61 LifecycleObserver::contextDestroyed();
65 if (m_observerToRemoveOnDestruct) { 62 if (m_observerToRemoveOnDestruct) {
66 lifecycleContext()->removeObserver(m_observerToRemoveOnDestruct.get( )); 63 lifecycleContext()->removeObserver(m_observerToRemoveOnDestruct.get( ));
67 m_observerToRemoveOnDestruct.clear(); 64 m_observerToRemoveOnDestruct.clear();
68 } 65 }
69 m_contextDestroyedCalled = true; 66 m_contextDestroyedCalled = true;
70 } 67 }
71 68
72 DEFINE_INLINE_TRACE() 69 DEFINE_INLINE_TRACE()
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 138
142 context->notifyContextDestroyed(); 139 context->notifyContextDestroyed();
143 EXPECT_EQ(observer->innerObserver(), nullptr); 140 EXPECT_EQ(observer->innerObserver(), nullptr);
144 context = nullptr; 141 context = nullptr;
145 Heap::collectAllGarbage(); 142 Heap::collectAllGarbage();
146 EXPECT_EQ(observer->lifecycleContext(), static_cast<DummyContext*>(0)); 143 EXPECT_EQ(observer->lifecycleContext(), static_cast<DummyContext*>(0));
147 EXPECT_TRUE(observer->contextDestroyedCalled()); 144 EXPECT_TRUE(observer->contextDestroyedCalled());
148 } 145 }
149 146
150 } // namespace blink 147 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698