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

Unified Diff: chrome/browser/ui/sync/tab_contents_synced_tab_delegate_unittest.cc

Issue 2777993002: [sync] Add regression test for TabContentsSyncedTabDelegate crash (Closed)
Patch Set: [sync] Add regression test for TabContentsSyncedTabDelegate crash Created 3 years, 9 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 | chrome/test/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/sync/tab_contents_synced_tab_delegate_unittest.cc
diff --git a/chrome/browser/ui/sync/tab_contents_synced_tab_delegate_unittest.cc b/chrome/browser/ui/sync/tab_contents_synced_tab_delegate_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2e59b903ac5481aeac975924e08a888c24bea5b9
--- /dev/null
+++ b/chrome/browser/ui/sync/tab_contents_synced_tab_delegate_unittest.cc
@@ -0,0 +1,47 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/sync/tab_contents_synced_tab_delegate.cc"
+
+#include "chrome/test/base/chrome_render_view_host_test_harness.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+class TabContentsSyncedTabDelegateTest
+ : public ChromeRenderViewHostTestHarness {
+ public:
+ TabContentsSyncedTabDelegateTest() : ChromeRenderViewHostTestHarness() {}
+ ~TabContentsSyncedTabDelegateTest() override {}
+
+ void SetUp() override {
+ content::RenderViewHostTestHarness::SetUp();
+
+ NavigateAndCommit(GURL("about:blank"));
+ TabContentsSyncedTabDelegate::CreateForWebContents(web_contents());
+ }
+};
+
+TEST_F(TabContentsSyncedTabDelegateTest, InvalidEntryIndexReturnsDefault) {
+ std::unique_ptr<content::WebContents> web_contents(CreateTestWebContents());
+
+ TabContentsSyncedTabDelegate::CreateForWebContents(web_contents.get());
+
+ TabContentsSyncedTabDelegate* delegate =
+ TabContentsSyncedTabDelegate::FromWebContents(web_contents.get());
+
+ // -1 and 2 are invalid indices because there's only one navigation
+ // recorded(the initial one to "about:blank")
+ EXPECT_EQ(delegate->GetFaviconURLAtIndex(-1), GURL());
+ EXPECT_EQ(delegate->GetFaviconURLAtIndex(2), GURL());
+
+ EXPECT_TRUE(
+ PageTransitionCoreTypeIs(delegate->GetTransitionAtIndex(-1),
+ ui::PageTransition::PAGE_TRANSITION_LINK));
+ EXPECT_TRUE(
+ PageTransitionCoreTypeIs(delegate->GetTransitionAtIndex(2),
+ ui::PageTransition::PAGE_TRANSITION_LINK));
+}
+
+} // namespace
« no previous file with comments | « no previous file | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698