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

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

Issue 857853002: Oilpan: fix platform unit tests after r188630. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 } 81 }
82 82
83 bool m_contextDestroyedCalled; 83 bool m_contextDestroyedCalled;
84 84
85 void unobserve() { observeContext(0); } 85 void unobserve() { observeContext(0); }
86 }; 86 };
87 87
88 TEST(LifecycleContextTest, shouldObserveContextDestroyed) 88 TEST(LifecycleContextTest, shouldObserveContextDestroyed)
89 { 89 {
90 OwnPtrWillBeRawPtr<DummyContext> context = adoptPtrWillBeNoop(new DummyConte xt()); 90 OwnPtrWillBeRawPtr<DummyContext> context = adoptPtrWillBeNoop(new DummyConte xt());
91 TestingObserver* observer = new TestingObserver(context.get()); 91 Persistent<TestingObserver> observer = new TestingObserver(context.get());
92 92
93 EXPECT_EQ(observer->lifecycleContext(), context.get()); 93 EXPECT_EQ(observer->lifecycleContext(), context.get());
94 EXPECT_FALSE(observer->m_contextDestroyedCalled); 94 EXPECT_FALSE(observer->m_contextDestroyedCalled);
95 context->notifyContextDestroyed(); 95 context->notifyContextDestroyed();
96 context.clear(); 96 context = nullptr;
97 Heap::collectAllGarbage();
97 EXPECT_EQ(observer->lifecycleContext(), static_cast<DummyContext*>(0)); 98 EXPECT_EQ(observer->lifecycleContext(), static_cast<DummyContext*>(0));
98 EXPECT_TRUE(observer->m_contextDestroyedCalled); 99 EXPECT_TRUE(observer->m_contextDestroyedCalled);
99 } 100 }
100 101
101 TEST(LifecycleContextTest, shouldNotObserveContextDestroyedIfUnobserve) 102 TEST(LifecycleContextTest, shouldNotObserveContextDestroyedIfUnobserve)
102 { 103 {
103 OwnPtrWillBeRawPtr<DummyContext> context = adoptPtrWillBeNoop(new DummyConte xt()); 104 OwnPtrWillBeRawPtr<DummyContext> context = adoptPtrWillBeNoop(new DummyConte xt());
104 TestingObserver* observer = new TestingObserver(context.get()); 105 Persistent<TestingObserver> observer = new TestingObserver(context.get());
105 observer->unobserve(); 106 observer->unobserve();
106 context->notifyContextDestroyed(); 107 context->notifyContextDestroyed();
107 context.clear(); 108 context = nullptr;
109 Heap::collectAllGarbage();
108 EXPECT_EQ(observer->lifecycleContext(), static_cast<DummyContext*>(0)); 110 EXPECT_EQ(observer->lifecycleContext(), static_cast<DummyContext*>(0));
109 EXPECT_FALSE(observer->m_contextDestroyedCalled); 111 EXPECT_FALSE(observer->m_contextDestroyedCalled);
110 } 112 }
111 113
112 } 114 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698