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

Unified Diff: third_party/WebKit/Source/platform/testing/TestingPlatformSupport.cpp

Issue 2588403002: TestingPlatformSupport: register Platform instance correctly (Closed)
Patch Set: LocaleMacTest needed same caller side fix Created 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/testing/TestingPlatformSupport.cpp
diff --git a/third_party/WebKit/Source/platform/testing/TestingPlatformSupport.cpp b/third_party/WebKit/Source/platform/testing/TestingPlatformSupport.cpp
index 42251b0e09c04f1f965b6847511014d35819d10c..b02e891d8c630e96fdeb10ecf44c6df7050dbe6f 100644
--- a/third_party/WebKit/Source/platform/testing/TestingPlatformSupport.cpp
+++ b/third_party/WebKit/Source/platform/testing/TestingPlatformSupport.cpp
@@ -141,12 +141,13 @@ TestingPlatformSupport::TestingPlatformSupport(const Config& config)
: m_config(config),
m_oldPlatform(Platform::current()),
m_interfaceProvider(new TestingInterfaceProvider) {
- ASSERT(m_oldPlatform);
- Platform::setCurrentPlatformForTesting(this);
+ DCHECK(m_oldPlatform);
}
TestingPlatformSupport::~TestingPlatformSupport() {
- Platform::setCurrentPlatformForTesting(m_oldPlatform);
+ // Checks if Platform::setCurrentPlatformForTesting() was correctly called
+ // after the construction.
+ DCHECK_NE(m_oldPlatform, Platform::current());
}
WebString TestingPlatformSupport::defaultLocale() {
@@ -332,8 +333,8 @@ ScopedUnittestsEnvironmentSetup::ScopedUnittestsEnvironmentSetup(int argc,
m_compositorSupport = WTF::wrapUnique(new cc_blink::WebCompositorSupportImpl);
m_testingPlatformConfig.compositorSupport = m_compositorSupport.get();
- m_testingPlatformSupport =
- WTF::makeUnique<TestingPlatformSupport>(m_testingPlatformConfig);
+ m_testingPlatformSupport.reset(
+ WTF::makeUnique<TestingPlatformSupport>(m_testingPlatformConfig));
ProcessHeap::init();
ThreadState::attachMainThread();
@@ -342,6 +343,9 @@ ScopedUnittestsEnvironmentSetup::ScopedUnittestsEnvironmentSetup(int argc,
HTTPNames::init();
}
-ScopedUnittestsEnvironmentSetup::~ScopedUnittestsEnvironmentSetup() {}
+ScopedUnittestsEnvironmentSetup::~ScopedUnittestsEnvironmentSetup() {
+ // Release TestingPlatformSupport instance while |m_platform| is alive.
+ m_testingPlatformSupport.reset(nullptr);
+}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698