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

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

Issue 2451573004: Not close bubble if the navigation is in-page (Closed)
Patch Set: address comment Created 4 years, 1 month 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/chrome_bubble_manager.cc ('k') | no next file » | 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"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, DontCloseBubbleWhenNavigationIsInPage) {
77 AddTab(browser(), GURL("https://foo/0"));
78
79 std::unique_ptr<MockBubbleDelegate> delegate(new MockBubbleDelegate);
80 BubbleReference bubble_ref = manager_->ShowBubble(std::move(delegate));
81
82 NavigateAndCommitActiveTab(GURL("https://foo/0#0"));
83
84 ASSERT_TRUE(bubble_ref)
85 << "The bubble shouldn't be destroyed when it is an in-page navigation.";
86 }
87
76 TEST_F(ChromeBubbleManagerTest, CloseMockBubbleOnOwningFrameDestroy) { 88 TEST_F(ChromeBubbleManagerTest, CloseMockBubbleOnOwningFrameDestroy) {
77 AddTab(browser(), GURL("https://foo/0")); 89 AddTab(browser(), GURL("https://foo/0"));
78 90
79 content::RenderFrameHostTester* main_frame = 91 content::RenderFrameHostTester* main_frame =
80 content::RenderFrameHostTester::For( 92 content::RenderFrameHostTester::For(
81 browser()->tab_strip_model()->GetWebContentsAt(0)->GetMainFrame()); 93 browser()->tab_strip_model()->GetWebContentsAt(0)->GetMainFrame());
82 94
83 content::RenderFrameHost* subframe0 = main_frame->AppendChild("subframe0"); 95 content::RenderFrameHost* subframe0 = main_frame->AppendChild("subframe0");
84 content::RenderFrameHostTester* subframe0_tester = 96 content::RenderFrameHostTester* subframe0_tester =
85 content::RenderFrameHostTester::For(subframe0); 97 content::RenderFrameHostTester::For(subframe0);
(...skipping 14 matching lines...) Expand all
100 112
101 subframe1_tester->Detach(); 113 subframe1_tester->Detach();
102 EXPECT_TRUE(bubble_ref) << "The bubble shouldn't be destroyed when a " 114 EXPECT_TRUE(bubble_ref) << "The bubble shouldn't be destroyed when a "
103 "non-owning frame is destroyed."; 115 "non-owning frame is destroyed.";
104 116
105 subframe0_tester->Detach(); 117 subframe0_tester->Detach();
106 EXPECT_FALSE(bubble_ref); 118 EXPECT_FALSE(bubble_ref);
107 } 119 }
108 120
109 } // namespace 121 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ui/chrome_bubble_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698