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

Unified Diff: components/sessions/content/content_serialized_navigation_builder_unittest.cc

Issue 2384403005: Fix flaky test ContentSerializedNavigationBuilderTest.ToNavigationEntry (Closed)
Patch Set: Address more feedback Created 4 years, 2 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
« no previous file with comments | « no previous file | components/sessions/content/content_serialized_navigation_driver.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sessions/content/content_serialized_navigation_builder_unittest.cc
diff --git a/components/sessions/content/content_serialized_navigation_builder_unittest.cc b/components/sessions/content/content_serialized_navigation_builder_unittest.cc
index 5f402982435e72c63e92c029be725b0a11911c3f..bdecc17d3edda8be1d07e971ea401c4312445777 100644
--- a/components/sessions/content/content_serialized_navigation_builder_unittest.cc
+++ b/components/sessions/content/content_serialized_navigation_builder_unittest.cc
@@ -87,20 +87,39 @@ void SetExtendedInfoForTest(content::NavigationEntry* entry) {
base::ASCIIToUTF16(kExtendedInfoValue1));
entry->SetExtraData(kExtendedInfoKey2,
base::ASCIIToUTF16(kExtendedInfoValue2));
- ContentSerializedNavigationDriver::GetInstance()->RegisterExtendedInfoHandler(
- kExtendedInfoKey1, base::WrapUnique<ExtendedInfoHandler>(
- new TestExtendedInfoHandler(kExtendedInfoKey1)));
- ContentSerializedNavigationDriver::GetInstance()->RegisterExtendedInfoHandler(
- kExtendedInfoKey2, base::WrapUnique<ExtendedInfoHandler>(
- new TestExtendedInfoHandler(kExtendedInfoKey2)));
}
} // namespace
+class ContentSerializedNavigationBuilderTest : public testing::Test {
+ public:
+ ContentSerializedNavigationBuilderTest() {}
+ ~ContentSerializedNavigationBuilderTest() override {}
+
+ void SetUp() override {
+ ContentSerializedNavigationDriver* driver =
+ ContentSerializedNavigationDriver::GetInstance();
+ driver->RegisterExtendedInfoHandler(
+ kExtendedInfoKey1, base::WrapUnique<ExtendedInfoHandler>(
+ new TestExtendedInfoHandler(kExtendedInfoKey1)));
+ driver->RegisterExtendedInfoHandler(
+ kExtendedInfoKey2, base::WrapUnique<ExtendedInfoHandler>(
+ new TestExtendedInfoHandler(kExtendedInfoKey2)));
+ }
+
+ void TearDown() override {
+ ContentSerializedNavigationDriver* driver =
+ ContentSerializedNavigationDriver::GetInstance();
+ driver->extended_info_handler_map_.clear();
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ContentSerializedNavigationBuilderTest);
+};
// Create a SerializedNavigationEntry from a NavigationEntry. All its fields
// should match the NavigationEntry's.
-TEST(ContentSerializedNavigationBuilderTest, FromNavigationEntry) {
+TEST_F(ContentSerializedNavigationBuilderTest, FromNavigationEntry) {
const std::unique_ptr<content::NavigationEntry> navigation_entry(
MakeNavigationEntryForTest());
SetExtendedInfoForTest(navigation_entry.get());
@@ -146,7 +165,7 @@ TEST(ContentSerializedNavigationBuilderTest, FromNavigationEntry) {
// a SerializedNavigationEntry and back. The new one should match the old one
// except for fields that aren't preserved, which should be set to
// expected values.
-TEST(ContentSerializedNavigationBuilderTest, ToNavigationEntry) {
+TEST_F(ContentSerializedNavigationBuilderTest, ToNavigationEntry) {
const std::unique_ptr<content::NavigationEntry> old_navigation_entry(
MakeNavigationEntryForTest());
SetExtendedInfoForTest(old_navigation_entry.get());
@@ -197,7 +216,7 @@ TEST(ContentSerializedNavigationBuilderTest, ToNavigationEntry) {
EXPECT_EQ(kExtendedInfoValue2, base::UTF16ToASCII(extra_data));
}
-TEST(ContentSerializedNavigationBuilderTest, SetPasswordState) {
+TEST_F(ContentSerializedNavigationBuilderTest, SetPasswordState) {
std::unique_ptr<content::NavigationEntry> entry(
content::NavigationEntry::Create());
« no previous file with comments | « no previous file | components/sessions/content/content_serialized_navigation_driver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698