Commit c32aac7c authored by Mostyn Bramley-Moore's avatar Mostyn Bramley-Moore Committed by Commit Bot

[jumbo] move duplicated test code to UnitTestHelpers.cpp

Fixes jumbo builds after https://chromium-review.googlesource.com/c/chromium/src/+/919199

Change-Id: I350604ae19b68859b622568b0d1ac78b223900a5
Reviewed-on: https://chromium-review.googlesource.com/920982Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Commit-Queue: Mostyn Bramley-Moore <mostynb@vewd.com>
Cr-Commit-Position: refs/heads/master@{#536971}
parent 1ddb5690
...@@ -20,31 +20,7 @@ ...@@ -20,31 +20,7 @@
using blink::URLTestHelpers::ToKURL; using blink::URLTestHelpers::ToKURL;
namespace blink { namespace blink {
namespace testing {
class LineReader {
public:
LineReader(const std::string& text) : text_(text), index_(0) {}
bool GetNextLine(std::string* line) {
line->clear();
if (index_ >= text_.length())
return false;
size_t end_of_line_index = text_.find("\r\n", index_);
if (end_of_line_index == std::string::npos) {
*line = text_.substr(index_);
index_ = text_.length();
return true;
}
*line = text_.substr(index_, end_of_line_index - index_);
index_ = end_of_line_index + 2;
return true;
}
private:
std::string text_;
size_t index_;
};
class MHTMLArchiveTest : public ::testing::Test { class MHTMLArchiveTest : public ::testing::Test {
public: public:
...@@ -303,4 +279,5 @@ TEST_F(MHTMLArchiveTest, MHTMLFromScheme) { ...@@ -303,4 +279,5 @@ TEST_F(MHTMLArchiveTest, MHTMLFromScheme) {
EXPECT_NE(nullptr, MHTMLArchive::Create(special_scheme_url, data.get())); EXPECT_NE(nullptr, MHTMLArchive::Create(special_scheme_url, data.get()));
} }
} // namespace testing
} // namespace blink } // namespace blink
...@@ -26,31 +26,7 @@ ...@@ -26,31 +26,7 @@
using blink::URLTestHelpers::ToKURL; using blink::URLTestHelpers::ToKURL;
namespace blink { namespace blink {
namespace testing {
class LineReader {
public:
LineReader(const std::string& text) : text_(text), index_(0) {}
bool GetNextLine(std::string* line) {
line->clear();
if (index_ >= text_.length())
return false;
size_t end_of_line_index = text_.find("\r\n", index_);
if (end_of_line_index == std::string::npos) {
*line = text_.substr(index_);
index_ = text_.length();
return true;
}
*line = text_.substr(index_, end_of_line_index - index_);
index_ = end_of_line_index + 2;
return true;
}
private:
std::string text_;
size_t index_;
};
class MHTMLLoadingTest : public ::testing::Test { class MHTMLLoadingTest : public ::testing::Test {
public: public:
...@@ -249,4 +225,5 @@ TEST_F(MHTMLLoadingTest, LoadMHTMLContainingSoftLineBreaks) { ...@@ -249,4 +225,5 @@ TEST_F(MHTMLLoadingTest, LoadMHTMLContainingSoftLineBreaks) {
"AVeryLongID012345678901234567890123456789012345678901234567890End")); "AVeryLongID012345678901234567890123456789012345678901234567890End"));
} }
} // namespace testing
} // namespace blink } // namespace blink
...@@ -112,5 +112,24 @@ scoped_refptr<SharedBuffer> ReadFromFile(const String& path) { ...@@ -112,5 +112,24 @@ scoped_refptr<SharedBuffer> ReadFromFile(const String& path) {
return SharedBuffer::Create(buffer.data(), buffer.size()); return SharedBuffer::Create(buffer.data(), buffer.size());
} }
LineReader::LineReader(const std::string& text) : text_(text), index_(0) {}
bool LineReader::GetNextLine(std::string* line) {
line->clear();
if (index_ >= text_.length())
return false;
size_t end_of_line_index = text_.find("\r\n", index_);
if (end_of_line_index == std::string::npos) {
*line = text_.substr(index_);
index_ = text_.length();
return true;
}
*line = text_.substr(index_, end_of_line_index - index_);
index_ = end_of_line_index + 2;
return true;
}
} // namespace testing } // namespace testing
} // namespace blink } // namespace blink
...@@ -68,6 +68,16 @@ String PlatformTestDataPath(const String& relative_path = String()); ...@@ -68,6 +68,16 @@ String PlatformTestDataPath(const String& relative_path = String());
scoped_refptr<SharedBuffer> ReadFromFile(const String& path); scoped_refptr<SharedBuffer> ReadFromFile(const String& path);
class LineReader {
public:
LineReader(const std::string& text);
bool GetNextLine(std::string* line);
private:
std::string text_;
size_t index_;
};
} // namespace testing } // namespace testing
} // namespace blink } // namespace blink
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment