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

Side by Side Diff: chrome/browser/ui/chrome_bubble_manager_unittest.cc

Issue 1865213004: Convert //chrome/browser/ui from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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
« no previous file with comments | « chrome/browser/ui/certificate_dialogs.cc ('k') | chrome/browser/ui/chrome_pages.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/chrome_bubble_manager.h" 5 #include "chrome/browser/ui/chrome_bubble_manager.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "chrome/browser/ui/tabs/tab_strip_model.h" 8 #include "chrome/browser/ui/tabs/tab_strip_model.h"
9 #include "chrome/test/base/browser_with_test_window_test.h" 9 #include "chrome/test/base/browser_with_test_window_test.h"
10 #include "components/bubble/bubble_controller.h" 10 #include "components/bubble/bubble_controller.h"
11 #include "components/bubble/bubble_manager_mocks.h" 11 #include "components/bubble/bubble_manager_mocks.h"
12 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
13 #include "content/public/test/test_renderer_host.h" 13 #include "content/public/test/test_renderer_host.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 namespace { 16 namespace {
17 17
18 class ChromeBubbleManagerTest : public BrowserWithTestWindowTest { 18 class ChromeBubbleManagerTest : public BrowserWithTestWindowTest {
19 public: 19 public:
20 ChromeBubbleManagerTest() {} 20 ChromeBubbleManagerTest() {}
21 21
22 // testing::Test: 22 // testing::Test:
23 void SetUp() override; 23 void SetUp() override;
24 void TearDown() override; 24 void TearDown() override;
25 25
26 protected: 26 protected:
27 scoped_ptr<ChromeBubbleManager> manager_; 27 std::unique_ptr<ChromeBubbleManager> manager_;
28 28
29 private: 29 private:
30 DISALLOW_COPY_AND_ASSIGN(ChromeBubbleManagerTest); 30 DISALLOW_COPY_AND_ASSIGN(ChromeBubbleManagerTest);
31 }; 31 };
32 32
33 void ChromeBubbleManagerTest::SetUp() { 33 void ChromeBubbleManagerTest::SetUp() {
34 BrowserWithTestWindowTest::SetUp(); 34 BrowserWithTestWindowTest::SetUp();
35 manager_.reset(new ChromeBubbleManager(browser()->tab_strip_model())); 35 manager_.reset(new ChromeBubbleManager(browser()->tab_strip_model()));
36 } 36 }
37 37
(...skipping 15 matching lines...) Expand all
53 bubble1->CloseBubble(BUBBLE_CLOSE_ACCEPTED); 53 bubble1->CloseBubble(BUBBLE_CLOSE_ACCEPTED);
54 bubble2->CloseBubble(BUBBLE_CLOSE_CANCELED); 54 bubble2->CloseBubble(BUBBLE_CLOSE_CANCELED);
55 55
56 ASSERT_FALSE(bubble1); 56 ASSERT_FALSE(bubble1);
57 ASSERT_FALSE(bubble2); 57 ASSERT_FALSE(bubble2);
58 } 58 }
59 59
60 TEST_F(ChromeBubbleManagerTest, CloseMockBubbleOnNavigate) { 60 TEST_F(ChromeBubbleManagerTest, CloseMockBubbleOnNavigate) {
61 AddTab(browser(), GURL("https://foo/0")); 61 AddTab(browser(), GURL("https://foo/0"));
62 62
63 scoped_ptr<MockBubbleDelegate> delegate(new MockBubbleDelegate); 63 std::unique_ptr<MockBubbleDelegate> delegate(new MockBubbleDelegate);
64 EXPECT_CALL(*delegate, ShouldClose(BUBBLE_CLOSE_NAVIGATED)) 64 EXPECT_CALL(*delegate, ShouldClose(BUBBLE_CLOSE_NAVIGATED))
65 .WillOnce(testing::Return(true)); 65 .WillOnce(testing::Return(true));
66 EXPECT_CALL(*delegate, DidClose(BUBBLE_CLOSE_NAVIGATED)); 66 EXPECT_CALL(*delegate, DidClose(BUBBLE_CLOSE_NAVIGATED));
67 EXPECT_CALL(*delegate, Destroyed()); 67 EXPECT_CALL(*delegate, Destroyed());
68 68
69 BubbleReference bubble_ref = manager_->ShowBubble(std::move(delegate)); 69 BubbleReference bubble_ref = manager_->ShowBubble(std::move(delegate));
70 70
71 NavigateAndCommitActiveTab(GURL("https://foo/1")); 71 NavigateAndCommitActiveTab(GURL("https://foo/1"));
72 72
73 ASSERT_FALSE(bubble_ref); 73 ASSERT_FALSE(bubble_ref);
74 } 74 }
75 75
76 TEST_F(ChromeBubbleManagerTest, CloseMockBubbleOnOwningFrameDestroy) { 76 TEST_F(ChromeBubbleManagerTest, CloseMockBubbleOnOwningFrameDestroy) {
77 AddTab(browser(), GURL("https://foo/0")); 77 AddTab(browser(), GURL("https://foo/0"));
78 78
79 content::RenderFrameHostTester* main_frame = 79 content::RenderFrameHostTester* main_frame =
80 content::RenderFrameHostTester::For( 80 content::RenderFrameHostTester::For(
81 browser()->tab_strip_model()->GetWebContentsAt(0)->GetMainFrame()); 81 browser()->tab_strip_model()->GetWebContentsAt(0)->GetMainFrame());
82 82
83 content::RenderFrameHost* subframe0 = main_frame->AppendChild("subframe0"); 83 content::RenderFrameHost* subframe0 = main_frame->AppendChild("subframe0");
84 content::RenderFrameHostTester* subframe0_tester = 84 content::RenderFrameHostTester* subframe0_tester =
85 content::RenderFrameHostTester::For(subframe0); 85 content::RenderFrameHostTester::For(subframe0);
86 86
87 content::RenderFrameHost* subframe1 = main_frame->AppendChild("subframe1"); 87 content::RenderFrameHost* subframe1 = main_frame->AppendChild("subframe1");
88 content::RenderFrameHostTester* subframe1_tester = 88 content::RenderFrameHostTester* subframe1_tester =
89 content::RenderFrameHostTester::For(subframe1); 89 content::RenderFrameHostTester::For(subframe1);
90 90
91 scoped_ptr<MockBubbleDelegate> delegate(new MockBubbleDelegate); 91 std::unique_ptr<MockBubbleDelegate> delegate(new MockBubbleDelegate);
92 EXPECT_CALL(*delegate, OwningFrame()) 92 EXPECT_CALL(*delegate, OwningFrame())
93 .WillRepeatedly(testing::Return(subframe0)); 93 .WillRepeatedly(testing::Return(subframe0));
94 EXPECT_CALL(*delegate, ShouldClose(BUBBLE_CLOSE_FRAME_DESTROYED)) 94 EXPECT_CALL(*delegate, ShouldClose(BUBBLE_CLOSE_FRAME_DESTROYED))
95 .WillOnce(testing::Return(true)); 95 .WillOnce(testing::Return(true));
96 EXPECT_CALL(*delegate, DidClose(BUBBLE_CLOSE_FRAME_DESTROYED)); 96 EXPECT_CALL(*delegate, DidClose(BUBBLE_CLOSE_FRAME_DESTROYED));
97 EXPECT_CALL(*delegate, Destroyed()); 97 EXPECT_CALL(*delegate, Destroyed());
98 98
99 BubbleReference bubble_ref = manager_->ShowBubble(std::move(delegate)); 99 BubbleReference bubble_ref = manager_->ShowBubble(std::move(delegate));
100 100
101 subframe1_tester->Detach(); 101 subframe1_tester->Detach();
102 EXPECT_TRUE(bubble_ref) << "The bubble shouldn't be destroyed when a " 102 EXPECT_TRUE(bubble_ref) << "The bubble shouldn't be destroyed when a "
103 "non-owning frame is destroyed."; 103 "non-owning frame is destroyed.";
104 104
105 subframe0_tester->Detach(); 105 subframe0_tester->Detach();
106 EXPECT_FALSE(bubble_ref); 106 EXPECT_FALSE(bubble_ref);
107 } 107 }
108 108
109 } // namespace 109 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ui/certificate_dialogs.cc ('k') | chrome/browser/ui/chrome_pages.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698