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

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

Issue 1456873003: More regular Platform implementations in unit tests (reland.) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: have GN disable c4267 also 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 a9ebd818405203f958b699ce2893785c499cf9fb..d3260d19e37f143f946b6370df91390d8bf65cb5 100644
--- a/third_party/WebKit/Source/web/tests/TextFinderTest.cpp
+++ b/third_party/WebKit/Source/web/tests/TextFinderTest.cpp
@@ -14,6 +14,7 @@
#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"
@@ -29,7 +30,15 @@ namespace blink {
class TextFinderTest : public ::testing::Test {
protected:
- void SetUp() override;
+ 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();
+ }
Document& document() const;
TextFinder& textFinder() const;
@@ -42,16 +51,6 @@ private:
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
{
return *m_document;
@@ -398,41 +397,19 @@ TEST_F(TextFinderTest, SequentialMatches)
class TextFinderFakeTimerTest : public TextFinderTest {
protected:
- void SetUp() override;
- void TearDown() override;
-
// A simple platform that mocks out the clock.
- class TimeProxyPlatform : public Platform {
+ class TimeProxyPlatform : public TestingPlatformSupport {
public:
TimeProxyPlatform()
- : m_timeCounter(0.)
- , m_fallbackPlatform(0)
- { }
-
- void install()
+ : m_timeCounter(m_oldPlatform->currentTimeSeconds())
{
- // 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_fallbackPlatform);
- return *m_fallbackPlatform;
+ ASSERT(m_oldPlatform);
+ return *m_oldPlatform;
}
// From blink::Platform:
@@ -441,47 +418,22 @@ protected:
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)
{
// Make a long string.
« 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