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

Side by Side Diff: third_party/WebKit/Source/platform/testing/TestingPlatformSupport.cpp

Issue 2588403002: TestingPlatformSupport: register Platform instance correctly (Closed)
Patch Set: review #32 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 TestingPlatformMockScheduler::TestingPlatformMockScheduler() {} 134 TestingPlatformMockScheduler::TestingPlatformMockScheduler() {}
135 TestingPlatformMockScheduler::~TestingPlatformMockScheduler() {} 135 TestingPlatformMockScheduler::~TestingPlatformMockScheduler() {}
136 136
137 TestingPlatformSupport::TestingPlatformSupport() 137 TestingPlatformSupport::TestingPlatformSupport()
138 : TestingPlatformSupport(TestingPlatformSupport::Config()) {} 138 : TestingPlatformSupport(TestingPlatformSupport::Config()) {}
139 139
140 TestingPlatformSupport::TestingPlatformSupport(const Config& config) 140 TestingPlatformSupport::TestingPlatformSupport(const Config& config)
141 : m_config(config), 141 : m_config(config),
142 m_oldPlatform(Platform::current()), 142 m_oldPlatform(Platform::current()),
143 m_interfaceProvider(new TestingInterfaceProvider) { 143 m_interfaceProvider(new TestingInterfaceProvider) {
144 ASSERT(m_oldPlatform); 144 DCHECK(m_oldPlatform);
145 Platform::setCurrentPlatformForTesting(this);
146 } 145 }
147 146
148 TestingPlatformSupport::~TestingPlatformSupport() { 147 TestingPlatformSupport::~TestingPlatformSupport() {
149 Platform::setCurrentPlatformForTesting(m_oldPlatform); 148 DCHECK_EQ(this, Platform::current());
150 } 149 }
151 150
152 WebString TestingPlatformSupport::defaultLocale() { 151 WebString TestingPlatformSupport::defaultLocale() {
153 return WebString::fromUTF8("en-US"); 152 return WebString::fromUTF8("en-US");
154 } 153 }
155 154
156 WebCompositorSupport* TestingPlatformSupport::compositorSupport() { 155 WebCompositorSupport* TestingPlatformSupport::compositorSupport() {
157 if (m_config.compositorSupport) 156 if (m_config.compositorSupport)
158 return m_config.compositorSupport; 157 return m_config.compositorSupport;
159 158
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 base::CommandLine::Init(argc, argv); 315 base::CommandLine::Init(argc, argv);
317 316
318 base::test::InitializeICUForTesting(); 317 base::test::InitializeICUForTesting();
319 318
320 m_discardableMemoryAllocator = 319 m_discardableMemoryAllocator =
321 WTF::wrapUnique(new base::TestDiscardableMemoryAllocator); 320 WTF::wrapUnique(new base::TestDiscardableMemoryAllocator);
322 base::DiscardableMemoryAllocator::SetInstance( 321 base::DiscardableMemoryAllocator::SetInstance(
323 m_discardableMemoryAllocator.get()); 322 m_discardableMemoryAllocator.get());
324 base::StatisticsRecorder::Initialize(); 323 base::StatisticsRecorder::Initialize();
325 324
326 m_platform = WTF::wrapUnique(new DummyPlatform); 325 m_dummyPlatform = WTF::wrapUnique(new DummyPlatform);
327 Platform::setCurrentPlatformForTesting(m_platform.get()); 326 Platform::setCurrentPlatformForTesting(m_dummyPlatform.get());
328 327
329 WTF::Partitions::initialize(nullptr); 328 WTF::Partitions::initialize(nullptr);
330 WTF::setTimeFunctionsForTesting(dummyCurrentTime); 329 WTF::setTimeFunctionsForTesting(dummyCurrentTime);
331 WTF::initialize(nullptr); 330 WTF::initialize(nullptr);
332 331
333 m_compositorSupport = WTF::wrapUnique(new cc_blink::WebCompositorSupportImpl); 332 m_compositorSupport = WTF::wrapUnique(new cc_blink::WebCompositorSupportImpl);
334 m_testingPlatformConfig.compositorSupport = m_compositorSupport.get(); 333 m_testingPlatformConfig.compositorSupport = m_compositorSupport.get();
335 m_testingPlatformSupport = 334 m_testingPlatformSupport =
336 WTF::makeUnique<TestingPlatformSupport>(m_testingPlatformConfig); 335 WTF::wrapUnique(new TestingPlatformSupport(m_testingPlatformConfig));
336 Platform::setCurrentPlatformForTesting(m_testingPlatformSupport.get());
337 337
338 ProcessHeap::init(); 338 ProcessHeap::init();
339 ThreadState::attachMainThread(); 339 ThreadState::attachMainThread();
340 ThreadState::current()->registerTraceDOMWrappers(nullptr, nullptr, nullptr, 340 ThreadState::current()->registerTraceDOMWrappers(nullptr, nullptr, nullptr,
341 nullptr); 341 nullptr);
342 HTTPNames::init(); 342 HTTPNames::init();
343 } 343 }
344 344
345 ScopedUnittestsEnvironmentSetup::~ScopedUnittestsEnvironmentSetup() {} 345 ScopedUnittestsEnvironmentSetup::~ScopedUnittestsEnvironmentSetup() {}
346 346
347 } // namespace blink 347 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698