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

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

Issue 2384403005: Fix flaky test ContentSerializedNavigationBuilderTest.ToNavigationEntry (Closed)
Patch Set: 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 | no next file » | 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..c48dc962dfb7e142a75f5434a6e984eae7f66aa9 100644
--- a/components/sessions/content/content_serialized_navigation_builder_unittest.cc
+++ b/components/sessions/content/content_serialized_navigation_builder_unittest.cc
@@ -87,20 +87,32 @@ 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 {}
+
+ static void SetUpTestCase() {
+ ContentSerializedNavigationDriver::GetInstance()->
sky 2016/10/06 17:01:47 While this works for your test, it means any other
jianli 2016/10/06 23:54:50 Done.
+ RegisterExtendedInfoHandler(
+ kExtendedInfoKey1,
+ base::WrapUnique<ExtendedInfoHandler>(
+ new TestExtendedInfoHandler(kExtendedInfoKey1)));
+ ContentSerializedNavigationDriver::GetInstance()->
+ RegisterExtendedInfoHandler(
+ kExtendedInfoKey2,
+ base::WrapUnique<ExtendedInfoHandler>(
+ new TestExtendedInfoHandler(kExtendedInfoKey2)));
+ }
+};
// 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 +158,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 +209,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 | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698