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

Side by Side 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, 8 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 unified diff | Download patch
OLDNEW
(Empty)
1 // 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
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
6 #include "chrome/browser/signin/fake_signin_manager_builder.h"
7 #include "chrome/browser/signin/signin_manager_factory.h"
8 #include "chrome/browser/ui/test/test_browser_dialog.h"
9 #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h"
10 #include "chrome/browser/ui/views/frame/browser_view.h"
11 #include "chrome/browser/ui/views/location_bar/star_view.h"
12 #include "chrome/browser/ui/views/toolbar/toolbar_view.h"
13 #include "chrome/test/base/browser_with_test_window_test.h"
14 #include "components/bookmarks/browser/bookmark_utils.h"
15 #include "components/bookmarks/test/bookmark_test_helpers.h"
16
17 namespace {
18
19 const char kTestBookmarkURL[] = "http://www.google.com";
20 const char kTestGaiaID[] = "test";
21 const char kTestUserEmail[] = "testuser@gtest.com";
22
23 } // namespace
24
25 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.
26 public:
27 BookmarkBubbleBrowserTest() {}
28
29 void SetUpOnMainThread() override {
30 TestingProfile::Builder builder;
31 builder.AddTestingFactory(SigninManagerFactory::GetInstance(),
32 BuildFakeSigninManagerBase);
33 profile_ = builder.Build();
34 profile_->CreateBookmarkModel(true);
35 bookmarks::BookmarkModel* bookmark_model =
36 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
37 bookmarks::test::WaitForBookmarkModelToLoad(bookmark_model);
38 bookmarks::AddIfNotBookmarked(bookmark_model, GURL(kTestBookmarkURL),
39 base::string16());
40 }
41
42 void TearDownOnMainThread() override { profile_.reset(); }
43
44 TestingProfile* profile() { return profile_.get(); }
45
46 void ShowDialog(const std::string& name) override {
47 BrowserView* browser_view =
sky 2017/03/29 21:54:34 GetBrowserViewForBrowser(browser()).
mrefaat 2017/03/30 17:37:15 Done.
48 reinterpret_cast<BrowserView*>(browser()->window());
49
50 if ("bookmark_details" == name) {
51 SigninManagerFactory::GetForProfile(profile())->SignOut(
52 signin_metrics::SIGNOUT_TEST,
53 signin_metrics::SignoutDelete::IGNORE_METRIC);
54 BookmarkBubbleView::ShowBubble(
55 browser_view->toolbar()->location_bar()->star_view(), gfx::Rect(),
56 nullptr, nullptr, nullptr, profile(), GURL(kTestBookmarkURL), true);
57 } else if ("bookmark_details_signed_in" == name) {
58 SigninManagerFactory::GetForProfile(profile())
59 ->SetAuthenticatedAccountInfo(kTestGaiaID, kTestUserEmail);
60 BookmarkBubbleView::ShowBubble(
61 browser_view->toolbar()->location_bar()->star_view(), gfx::Rect(),
62 nullptr, nullptr, nullptr, profile(), GURL(kTestBookmarkURL), true);
63 #if defined(OS_WIN)
64 } else if ("ios_promotion" == name) {
65 SigninManagerFactory::GetForProfile(profile())
66 ->SetAuthenticatedAccountInfo(kTestGaiaID, kTestUserEmail);
67 BookmarkBubbleView::ShowBubble(
68 browser_view->toolbar()->location_bar()->star_view(), gfx::Rect(),
69 nullptr, nullptr, nullptr, profile(), GURL(kTestBookmarkURL), true);
70 BookmarkBubbleView::bookmark_bubble()->ShowIOSPromotion();
71 #endif
72 }
73 }
74
75 protected:
76 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.
77
78 private:
79 DISALLOW_COPY_AND_ASSIGN(BookmarkBubbleBrowserTest);
80 };
81
82 IN_PROC_BROWSER_TEST_F(BookmarkBubbleBrowserTest,
83 InvokeDialog_bookmark_details) {
84 RunDialog();
85 }
86
87 IN_PROC_BROWSER_TEST_F(BookmarkBubbleBrowserTest,
88 InvokeDialog_bookmark_details_signed_in) {
89 RunDialog();
90 }
91
92 #if defined(OS_WIN)
93 IN_PROC_BROWSER_TEST_F(BookmarkBubbleBrowserTest, InvokeDialog_ios_promotion) {
94 RunDialog();
95 }
96 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698