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

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

Issue 14598011: Convert a BrowserView.BrowserViewLayout interactive_uitest to unit_test (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/ui/views/frame/browser_view_unittest.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/ui/browser_commands.h" 7 #include "chrome/browser/ui/browser_commands.h"
9 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" 8 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
10 #include "chrome/browser/ui/views/frame/browser_view_layout.h"
11 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" 9 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
12 #include "chrome/browser/ui/views/frame/top_container_view.h"
13 #include "chrome/browser/ui/views/infobars/infobar_container_view.h"
14 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 10 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
15 #include "chrome/browser/ui/views/tabs/tab_strip.h" 11 #include "chrome/browser/ui/views/tabs/tab.h"
16 #include "chrome/browser/ui/views/toolbar_view.h" 12 #include "chrome/browser/ui/views/toolbar_view.h"
17 #include "chrome/common/url_constants.h" 13 #include "chrome/common/url_constants.h"
18 #include "chrome/test/base/in_process_browser_test.h" 14 #include "chrome/test/base/in_process_browser_test.h"
19 #include "chrome/test/base/ui_test_utils.h" 15 #include "chrome/test/base/ui_test_utils.h"
20 #include "ui/views/controls/single_split_view.h"
21 #include "ui/views/controls/webview/webview.h" 16 #include "ui/views/controls/webview/webview.h"
22 #include "ui/views/focus/focus_manager.h" 17 #include "ui/views/focus/focus_manager.h"
23 #include "ui/views/window/non_client_view.h" 18 #include "ui/views/window/non_client_view.h"
24 19
25 #if defined(OS_CHROMEOS) 20 #if defined(OS_CHROMEOS)
26 #include "chrome/browser/autocomplete/autocomplete_controller.h" 21 #include "chrome/browser/autocomplete/autocomplete_controller.h"
27 #include "chrome/browser/search/search.h" 22 #include "chrome/browser/search/search.h"
28 #include "chrome/browser/ui/omnibox/omnibox_view.h" 23 #include "chrome/browser/ui/omnibox/omnibox_view.h"
29 #include "chrome/browser/ui/search/instant_test_utils.h" 24 #include "chrome/browser/ui/search/instant_test_utils.h"
30 #include "chrome/browser/ui/views/frame/contents_container.h" 25 #include "chrome/browser/ui/views/frame/contents_container.h"
31 #include "chrome/common/chrome_notification_types.h" 26 #include "chrome/common/chrome_notification_types.h"
32 #include "content/public/browser/notification_service.h" 27 #include "content/public/browser/notification_service.h"
33 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 28 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
34 #endif 29 #endif
35 30
36 using views::FocusManager; 31 using views::FocusManager;
37 32
38 namespace { 33 namespace {
39 34
40 // Tab strip bounds depend on the window frame sizes.
41 gfx::Point ExpectedTabStripOrigin(BrowserView* browser_view) {
42 gfx::Rect tabstrip_bounds(
43 browser_view->frame()->GetBoundsForTabStrip(browser_view->tabstrip()));
44 gfx::Point tabstrip_origin(tabstrip_bounds.origin());
45 views::View::ConvertPointToTarget(browser_view->parent(),
46 browser_view,
47 &tabstrip_origin);
48 return tabstrip_origin;
49 }
50
51 // Returns the bounds of |view| in widget coordinates. 35 // Returns the bounds of |view| in widget coordinates.
52 gfx::Rect GetRectInWidget(views::View* view) { 36 gfx::Rect GetRectInWidget(views::View* view) {
53 return view->ConvertRectToWidget(view->GetLocalBounds()); 37 return view->ConvertRectToWidget(view->GetLocalBounds());
54 } 38 }
55 39
56 } 40 }
57 41
58 typedef InProcessBrowserTest BrowserViewTest; 42 typedef InProcessBrowserTest BrowserViewTest;
59 43
60 IN_PROC_BROWSER_TEST_F(BrowserViewTest, BrowserView) {
61 BookmarkBarView::DisableAnimationsForTesting(true);
62
63 BrowserView* browser_view = static_cast<BrowserView*>(browser()->window());
64 TopContainerView* top_container = browser_view->top_container();
65 TabStrip* tabstrip = browser_view->tabstrip();
66 ToolbarView* toolbar = browser_view->toolbar();
67 views::SingleSplitView* contents_split =
68 browser_view->GetContentsSplitForTest();
69 views::WebView* contents_web_view =
70 browser_view->GetContentsWebViewForTest();
71
72 // Verify the view hierarchy.
73 EXPECT_EQ(top_container, browser_view->tabstrip()->parent());
74 EXPECT_EQ(top_container, browser_view->toolbar()->parent());
75 EXPECT_EQ(top_container, browser_view->GetBookmarkBarView()->parent());
76 EXPECT_EQ(browser_view, browser_view->infobar_container()->parent());
77
78 // Top container is at the front of the view hierarchy.
79 EXPECT_EQ(browser_view->child_count() - 1,
80 browser_view->GetIndexOf(top_container));
81
82 // Verify basic layout.
83 EXPECT_EQ(0, top_container->x());
84 EXPECT_EQ(0, top_container->y());
85 EXPECT_EQ(browser_view->width(), top_container->width());
86 // Tabstrip layout varies based on window frame sizes.
87 gfx::Point expected_tabstrip_origin = ExpectedTabStripOrigin(browser_view);
88 EXPECT_EQ(expected_tabstrip_origin.x(), tabstrip->x());
89 EXPECT_EQ(expected_tabstrip_origin.y(), tabstrip->y());
90 EXPECT_EQ(0, toolbar->x());
91 EXPECT_EQ(
92 tabstrip->bounds().bottom() -
93 BrowserViewLayout::kToolbarTabStripVerticalOverlap,
94 toolbar->y());
95 EXPECT_EQ(0, contents_split->x());
96 EXPECT_EQ(toolbar->bounds().bottom(), contents_split->y());
97 EXPECT_EQ(0, contents_web_view->x());
98 EXPECT_EQ(0, contents_web_view->y());
99
100 // Verify bookmark bar visibility.
101 BookmarkBarView* bookmark_bar = browser_view->GetBookmarkBarView();
102 EXPECT_FALSE(bookmark_bar->visible());
103 EXPECT_FALSE(bookmark_bar->IsDetached());
104 chrome::ExecuteCommand(browser(), IDC_SHOW_BOOKMARK_BAR);
105 EXPECT_TRUE(bookmark_bar->visible());
106 EXPECT_FALSE(bookmark_bar->IsDetached());
107 chrome::ExecuteCommand(browser(), IDC_SHOW_BOOKMARK_BAR);
108 EXPECT_FALSE(bookmark_bar->visible());
109 EXPECT_FALSE(bookmark_bar->IsDetached());
110
111 // Bookmark bar is reparented to BrowserView on NTP.
112 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
113 EXPECT_TRUE(bookmark_bar->visible());
114 EXPECT_TRUE(bookmark_bar->IsDetached());
115 EXPECT_EQ(browser_view, bookmark_bar->parent());
116 // Top container is still in front.
117 EXPECT_EQ(browser_view->child_count() - 1,
118 browser_view->GetIndexOf(top_container));
119
120 // Bookmark bar layout on NTP.
121 EXPECT_EQ(0, bookmark_bar->x());
122 EXPECT_EQ(
123 tabstrip->bounds().bottom() +
124 toolbar->height() -
125 BrowserViewLayout::kToolbarTabStripVerticalOverlap -
126 views::NonClientFrameView::kClientEdgeThickness,
127 bookmark_bar->y());
128 EXPECT_EQ(toolbar->bounds().bottom(), contents_split->y());
129 // Contents view has a "top margin" pushing it below the bookmark bar.
130 EXPECT_EQ(bookmark_bar->height() -
131 views::NonClientFrameView::kClientEdgeThickness,
132 contents_web_view->y());
133
134 // Bookmark bar is parented back to top container on normal page.
135 ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
136 EXPECT_FALSE(bookmark_bar->visible());
137 EXPECT_FALSE(bookmark_bar->IsDetached());
138 EXPECT_EQ(top_container, bookmark_bar->parent());
139 // Top container is still in front.
140 EXPECT_EQ(browser_view->child_count() - 1,
141 browser_view->GetIndexOf(top_container));
142
143 BookmarkBarView::DisableAnimationsForTesting(false);
144 }
145
146 // Active window and focus testing is not reliable on Windows crbug.com/79493 44 // Active window and focus testing is not reliable on Windows crbug.com/79493
147 // TODO(linux_aura) http://crbug.com/163931 45 // TODO(linux_aura) http://crbug.com/163931
148 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(US E_AURA)) 46 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(US E_AURA))
149 #define MAYBE_FullscreenClearsFocus DISABLED_FullscreenClearsFocus 47 #define MAYBE_FullscreenClearsFocus DISABLED_FullscreenClearsFocus
150 #else 48 #else
151 #define MAYBE_FullscreenClearsFocus FullscreenClearsFocus 49 #define MAYBE_FullscreenClearsFocus FullscreenClearsFocus
152 #endif 50 #endif
153 IN_PROC_BROWSER_TEST_F(BrowserViewTest, MAYBE_FullscreenClearsFocus) { 51 IN_PROC_BROWSER_TEST_F(BrowserViewTest, MAYBE_FullscreenClearsFocus) {
154 BrowserView* browser_view = static_cast<BrowserView*>(browser()->window()); 52 BrowserView* browser_view = static_cast<BrowserView*>(browser()->window());
155 LocationBarView* location_bar_view = browser_view->GetLocationBarView(); 53 LocationBarView* location_bar_view = browser_view->GetLocationBarView();
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 EXPECT_TRUE(browser_view->immersive_mode_controller()->IsRevealed()); 169 EXPECT_TRUE(browser_view->immersive_mode_controller()->IsRevealed());
272 // The active web contents are aligned with the toolbar. 170 // The active web contents are aligned with the toolbar.
273 gfx::Rect web_view_rect_in_widget = GetRectInWidget( 171 gfx::Rect web_view_rect_in_widget = GetRectInWidget(
274 browser_view->GetContentsContainerForTest()->GetActiveWebViewForTest()); 172 browser_view->GetContentsContainerForTest()->GetActiveWebViewForTest());
275 EXPECT_EQ(GetRectInWidget(toolbar).bottom(), web_view_rect_in_widget.y()); 173 EXPECT_EQ(GetRectInWidget(toolbar).bottom(), web_view_rect_in_widget.y());
276 174
277 BookmarkBarView::DisableAnimationsForTesting(false); 175 BookmarkBarView::DisableAnimationsForTesting(false);
278 } 176 }
279 177
280 #endif // defined(OS_CHROMEOS) 178 #endif // defined(OS_CHROMEOS)
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/frame/browser_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698