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

Unified Diff: third_party/WebKit/Source/web/tests/TextFinderTest.cpp

Issue 1466603003: Revert of More regular Platform implementations in unit tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/web/ImageDecodeBench.cpp ('k') | third_party/WebKit/Source/web/web_tests.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/web/tests/TextFinderTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/TextFinderTest.cpp b/third_party/WebKit/Source/web/tests/TextFinderTest.cpp
index d3260d19e37f143f946b6370df91390d8bf65cb5..a9ebd818405203f958b699ce2893785c499cf9fb 100644
--- a/third_party/WebKit/Source/web/tests/TextFinderTest.cpp
+++ b/third_party/WebKit/Source/web/tests/TextFinderTest.cpp
@@ -14,7 +14,6 @@
#include "core/html/HTMLElement.h"
#include "core/layout/TextAutosizer.h"
#include "core/page/Page.h"
-#include "platform/testing/TestingPlatformSupport.h"
#include "platform/testing/UnitTestHelpers.h"
#include "public/platform/Platform.h"
#include "public/web/WebDocument.h"
@@ -30,15 +29,7 @@
class TextFinderTest : public ::testing::Test {
protected:
- TextFinderTest()
- {
- m_webViewHelper.initialize();
- WebLocalFrameImpl& frameImpl = *m_webViewHelper.webViewImpl()->mainFrameImpl();
- frameImpl.viewImpl()->resize(WebSize(640, 480));
- frameImpl.viewImpl()->updateAllLifecyclePhases();
- m_document = PassRefPtrWillBeRawPtr<Document>(frameImpl.document());
- m_textFinder = &frameImpl.ensureTextFinder();
- }
+ void SetUp() override;
Document& document() const;
TextFinder& textFinder() const;
@@ -50,6 +41,16 @@
RefPtrWillBePersistent<Document> m_document;
RawPtrWillBePersistent<TextFinder> m_textFinder;
};
+
+void TextFinderTest::SetUp()
+{
+ m_webViewHelper.initialize();
+ WebLocalFrameImpl& frameImpl = *m_webViewHelper.webViewImpl()->mainFrameImpl();
+ frameImpl.viewImpl()->resize(WebSize(640, 480));
+ frameImpl.viewImpl()->updateAllLifecyclePhases();
+ m_document = PassRefPtrWillBeRawPtr<Document>(frameImpl.document());
+ m_textFinder = &frameImpl.ensureTextFinder();
+}
Document& TextFinderTest::document() const
{
@@ -397,19 +398,41 @@
class TextFinderFakeTimerTest : public TextFinderTest {
protected:
+ void SetUp() override;
+ void TearDown() override;
+
// A simple platform that mocks out the clock.
- class TimeProxyPlatform : public TestingPlatformSupport {
+ class TimeProxyPlatform : public Platform {
public:
TimeProxyPlatform()
- : m_timeCounter(m_oldPlatform->currentTimeSeconds())
- {
+ : m_timeCounter(0.)
+ , m_fallbackPlatform(0)
+ { }
+
+ void install()
+ {
+ // Check that the proxy wasn't installed yet.
+ ASSERT_NE(Platform::current(), this);
+ m_fallbackPlatform = Platform::current();
+ m_timeCounter = m_fallbackPlatform->currentTimeSeconds();
+ Platform::initialize(this);
+ ASSERT_EQ(Platform::current(), this);
+ }
+
+ void remove()
+ {
+ // Check that the proxy was installed.
+ ASSERT_EQ(Platform::current(), this);
+ Platform::initialize(m_fallbackPlatform);
+ ASSERT_EQ(Platform::current(), m_fallbackPlatform);
+ m_fallbackPlatform = 0;
}
private:
Platform& ensureFallback()
{
- ASSERT(m_oldPlatform);
- return *m_oldPlatform;
+ ASSERT(m_fallbackPlatform);
+ return *m_fallbackPlatform;
}
// From blink::Platform:
@@ -418,21 +441,46 @@
return ++m_timeCounter;
}
+ // These blink::Platform methods must be overriden to make a usable object.
+ void cryptographicallyRandomValues(unsigned char* buffer, size_t length) override
+ {
+ ensureFallback().cryptographicallyRandomValues(buffer, length);
+ }
+
+ const unsigned char* getTraceCategoryEnabledFlag(const char* categoryName) override
+ {
+ return ensureFallback().getTraceCategoryEnabledFlag(categoryName);
+ }
+
// These two methods allow timers to work correctly.
double monotonicallyIncreasingTimeSeconds() override
{
return ensureFallback().monotonicallyIncreasingTimeSeconds();
}
+ WebThread* currentThread() override { return ensureFallback().currentThread(); }
WebUnitTestSupport* unitTestSupport() override { return ensureFallback().unitTestSupport(); }
WebString defaultLocale() override { return ensureFallback().defaultLocale(); }
WebCompositorSupport* compositorSupport() override { return ensureFallback().compositorSupport(); }
double m_timeCounter;
+ Platform* m_fallbackPlatform;
};
TimeProxyPlatform m_proxyTimePlatform;
};
+
+void TextFinderFakeTimerTest::SetUp()
+{
+ TextFinderTest::SetUp();
+ m_proxyTimePlatform.install();
+}
+
+void TextFinderFakeTimerTest::TearDown()
+{
+ m_proxyTimePlatform.remove();
+ TextFinderTest::TearDown();
+}
TEST_F(TextFinderFakeTimerTest, ScopeWithTimeouts)
{
« no previous file with comments | « third_party/WebKit/Source/web/ImageDecodeBench.cpp ('k') | third_party/WebKit/Source/web/web_tests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698