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

Side by Side Diff: chrome/browser/ui/views/frame/browser_view_unittest.cc

Issue 2946813002: Bookmark disappear first when closing browser (Closed)
Patch Set: Return back to earlier fix Created 3 years, 5 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/views/frame/browser_view.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/views/frame/browser_view.h" 5 #include "chrome/browser/ui/views/frame/browser_view.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "chrome/app/chrome_command_ids.h" 8 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/ui/bookmarks/bookmark_bar_constants.h" 9 #include "chrome/browser/ui/bookmarks/bookmark_bar_constants.h"
10 #include "chrome/browser/ui/browser_commands.h" 10 #include "chrome/browser/ui/browser_commands.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h"
11 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" 12 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
12 #include "chrome/browser/ui/views/frame/browser_view_layout.h" 13 #include "chrome/browser/ui/views/frame/browser_view_layout.h"
13 #include "chrome/browser/ui/views/frame/test_with_browser_view.h" 14 #include "chrome/browser/ui/views/frame/test_with_browser_view.h"
14 #include "chrome/browser/ui/views/frame/top_container_view.h" 15 #include "chrome/browser/ui/views/frame/top_container_view.h"
15 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" 16 #include "chrome/browser/ui/views/infobars/infobar_container_view.h"
16 #include "chrome/browser/ui/views/tabs/tab_strip.h" 17 #include "chrome/browser/ui/views/tabs/tab_strip.h"
17 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" 18 #include "chrome/browser/ui/views/toolbar/toolbar_view.h"
18 #include "chrome/common/url_constants.h" 19 #include "chrome/common/url_constants.h"
19 #include "ui/base/accelerators/accelerator.h" 20 #include "ui/base/accelerators/accelerator.h"
20 #include "ui/views/controls/webview/webview.h" 21 #include "ui/views/controls/webview/webview.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 const ui::Accelerator kLocationRepeatAccel( 176 const ui::Accelerator kLocationRepeatAccel(
176 ui::VKEY_L, kPlatformModifier | ui::EF_IS_REPEAT); 177 ui::VKEY_L, kPlatformModifier | ui::EF_IS_REPEAT);
177 EXPECT_FALSE(browser_view()->AcceleratorPressed(kLocationRepeatAccel)); 178 EXPECT_FALSE(browser_view()->AcceleratorPressed(kLocationRepeatAccel));
178 179
179 // A repeated Ctrl-Tab accelerator should be processed. 180 // A repeated Ctrl-Tab accelerator should be processed.
180 const ui::Accelerator kNextTabRepeatAccel( 181 const ui::Accelerator kNextTabRepeatAccel(
181 ui::VKEY_TAB, ui::EF_CONTROL_DOWN | ui::EF_IS_REPEAT); 182 ui::VKEY_TAB, ui::EF_CONTROL_DOWN | ui::EF_IS_REPEAT);
182 EXPECT_TRUE(browser_view()->AcceleratorPressed(kNextTabRepeatAccel)); 183 EXPECT_TRUE(browser_view()->AcceleratorPressed(kNextTabRepeatAccel));
183 } 184 }
184 185
186 // Test that the bookmark bar view's parent is not set to nullptr when closing
187 // the browser. If the parent is set to nullptr, then the bookmark bar
188 // disappears before the browser is closed, which looks weird.
189 TEST_F(BrowserViewTest, BookmarkBarParentIsNotNullOnShutdown) {
190 BookmarkBarView::DisableAnimationsForTesting(true);
191
192 Browser* browser = browser_view()->browser();
193 TabStripModel* tab_strip_model = browser->tab_strip_model();
194 EXPECT_EQ(0, tab_strip_model->count());
195
196 AddTab(browser, GURL("about:blank"));
197 EXPECT_EQ(1, tab_strip_model->count());
198
199 BookmarkBarView* bookmark_bar = browser_view()->GetBookmarkBarView();
200 chrome::ExecuteCommand(browser, IDC_SHOW_BOOKMARK_BAR);
201 EXPECT_NE(nullptr, bookmark_bar->parent());
202
203 tab_strip_model->CloseWebContentsAt(tab_strip_model->active_index(), 0);
204 EXPECT_EQ(0, tab_strip_model->count());
205 EXPECT_NE(nullptr, bookmark_bar->parent());
206
207 BookmarkBarView::DisableAnimationsForTesting(false);
208 }
209
185 class BrowserViewHostedAppTest : public TestWithBrowserView { 210 class BrowserViewHostedAppTest : public TestWithBrowserView {
186 public: 211 public:
187 BrowserViewHostedAppTest() : TestWithBrowserView(Browser::TYPE_POPUP, true) {} 212 BrowserViewHostedAppTest() : TestWithBrowserView(Browser::TYPE_POPUP, true) {}
188 ~BrowserViewHostedAppTest() override {} 213 ~BrowserViewHostedAppTest() override {}
189 214
190 private: 215 private:
191 DISALLOW_COPY_AND_ASSIGN(BrowserViewHostedAppTest); 216 DISALLOW_COPY_AND_ASSIGN(BrowserViewHostedAppTest);
192 }; 217 };
193 218
194 // Test basic layout for hosted apps. 219 // Test basic layout for hosted apps.
(...skipping 22 matching lines...) Expand all
217 header_offset.y(); 242 header_offset.y();
218 243
219 // The web contents should be flush with the bottom of the header. 244 // The web contents should be flush with the bottom of the header.
220 EXPECT_EQ(bottom_of_header, contents_container->y()); 245 EXPECT_EQ(bottom_of_header, contents_container->y());
221 246
222 // The find bar should overlap the 1px header/web-contents separator at the 247 // The find bar should overlap the 1px header/web-contents separator at the
223 // bottom of the header. 248 // bottom of the header.
224 EXPECT_LT(browser_view()->GetFindBarBoundingBox().y(), 249 EXPECT_LT(browser_view()->GetFindBarBoundingBox().y(),
225 browser_view()->frame()->GetTopInset(false)); 250 browser_view()->frame()->GetTopInset(false));
226 } 251 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698