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

Unified Diff: chrome/browser/ui/views/bookmarks/bookmark_bubble_browsertest.cc

Issue 2781553003: Integrate Desktop iOS promotion with bookmarks. (Closed)
Patch Set: Add Browser test and address comments 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
Index: chrome/browser/ui/views/bookmarks/bookmark_bubble_browsertest.cc
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bubble_browsertest.cc b/chrome/browser/ui/views/bookmarks/bookmark_bubble_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8f7fc46e51db6afbe709583265a3f5371c57c6af
--- /dev/null
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bubble_browsertest.cc
@@ -0,0 +1,96 @@
+// Copyright (c) 2017 The Chromium Authors. All rights reserved.
sky 2017/03/29 21:54:34 Name this file bookmark_bubble_view_browsertest to
sky 2017/03/29 21:54:36 no (c) (see style guide)
mrefaat 2017/03/30 17:37:14 Done.
mrefaat 2017/03/30 17:37:15 Ack, But we need to change the presubmit rule, i g
sky 2017/03/30 20:30:17 You must be doing something else wrong if you need
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/bookmarks/bookmark_model_factory.h"
+#include "chrome/browser/signin/fake_signin_manager_builder.h"
+#include "chrome/browser/signin/signin_manager_factory.h"
+#include "chrome/browser/ui/test/test_browser_dialog.h"
+#include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h"
+#include "chrome/browser/ui/views/frame/browser_view.h"
+#include "chrome/browser/ui/views/location_bar/star_view.h"
+#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
+#include "chrome/test/base/browser_with_test_window_test.h"
+#include "components/bookmarks/browser/bookmark_utils.h"
+#include "components/bookmarks/test/bookmark_test_helpers.h"
+
+namespace {
+
+const char kTestBookmarkURL[] = "http://www.google.com";
+const char kTestGaiaID[] = "test";
+const char kTestUserEmail[] = "testuser@gtest.com";
+
+} // namespace
+
+class BookmarkBubbleBrowserTest : public DialogBrowserTest {
sky 2017/03/29 21:54:35 And name this to match bookmarkbubbleview too.
mrefaat 2017/03/30 17:37:15 Done.
+ public:
+ BookmarkBubbleBrowserTest() {}
+
+ void SetUpOnMainThread() override {
+ TestingProfile::Builder builder;
+ builder.AddTestingFactory(SigninManagerFactory::GetInstance(),
+ BuildFakeSigninManagerBase);
+ profile_ = builder.Build();
+ profile_->CreateBookmarkModel(true);
+ bookmarks::BookmarkModel* bookmark_model =
+ BookmarkModelFactory::GetForBrowserContext(profile());
sky 2017/03/29 21:54:37 You use profile_ above, and profile() here. Please
mrefaat 2017/03/30 17:37:15 i thought its better than using profile_.get() eve
+ bookmarks::test::WaitForBookmarkModelToLoad(bookmark_model);
+ bookmarks::AddIfNotBookmarked(bookmark_model, GURL(kTestBookmarkURL),
+ base::string16());
+ }
+
+ void TearDownOnMainThread() override { profile_.reset(); }
+
+ TestingProfile* profile() { return profile_.get(); }
+
+ void ShowDialog(const std::string& name) override {
+ BrowserView* browser_view =
sky 2017/03/29 21:54:34 GetBrowserViewForBrowser(browser()).
mrefaat 2017/03/30 17:37:15 Done.
+ reinterpret_cast<BrowserView*>(browser()->window());
+
+ if ("bookmark_details" == name) {
+ SigninManagerFactory::GetForProfile(profile())->SignOut(
+ signin_metrics::SIGNOUT_TEST,
+ signin_metrics::SignoutDelete::IGNORE_METRIC);
+ BookmarkBubbleView::ShowBubble(
+ browser_view->toolbar()->location_bar()->star_view(), gfx::Rect(),
+ nullptr, nullptr, nullptr, profile(), GURL(kTestBookmarkURL), true);
+ } else if ("bookmark_details_signed_in" == name) {
+ SigninManagerFactory::GetForProfile(profile())
+ ->SetAuthenticatedAccountInfo(kTestGaiaID, kTestUserEmail);
+ BookmarkBubbleView::ShowBubble(
+ browser_view->toolbar()->location_bar()->star_view(), gfx::Rect(),
+ nullptr, nullptr, nullptr, profile(), GURL(kTestBookmarkURL), true);
+#if defined(OS_WIN)
+ } else if ("ios_promotion" == name) {
+ SigninManagerFactory::GetForProfile(profile())
+ ->SetAuthenticatedAccountInfo(kTestGaiaID, kTestUserEmail);
+ BookmarkBubbleView::ShowBubble(
+ browser_view->toolbar()->location_bar()->star_view(), gfx::Rect(),
+ nullptr, nullptr, nullptr, profile(), GURL(kTestBookmarkURL), true);
+ BookmarkBubbleView::bookmark_bubble()->ShowIOSPromotion();
+#endif
+ }
+ }
+
+ protected:
+ std::unique_ptr<TestingProfile> profile_;
sky 2017/03/29 21:54:34 Move to private_ ? Tests allow for protected membe
mrefaat 2017/03/30 17:37:15 Done.
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(BookmarkBubbleBrowserTest);
+};
+
+IN_PROC_BROWSER_TEST_F(BookmarkBubbleBrowserTest,
+ InvokeDialog_bookmark_details) {
+ RunDialog();
+}
+
+IN_PROC_BROWSER_TEST_F(BookmarkBubbleBrowserTest,
+ InvokeDialog_bookmark_details_signed_in) {
+ RunDialog();
+}
+
+#if defined(OS_WIN)
+IN_PROC_BROWSER_TEST_F(BookmarkBubbleBrowserTest, InvokeDialog_ios_promotion) {
+ RunDialog();
+}
+#endif

Powered by Google App Engine
This is Rietveld 408576698