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

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

Issue 13684002: cros: Instant extended support for immersive fullscreen (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 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 | Annotate | Revision Log
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" 7 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/ui/browser_commands.h" 8 #include "chrome/browser/ui/browser_commands.h"
9 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" 9 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
10 #include "chrome/browser/ui/views/frame/browser_view_layout.h"
10 #include "chrome/browser/ui/views/frame/top_container_view.h" 11 #include "chrome/browser/ui/views/frame/top_container_view.h"
11 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" 12 #include "chrome/browser/ui/views/infobars/infobar_container_view.h"
12 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 13 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
13 #include "chrome/browser/ui/views/tabs/tab_strip.h" 14 #include "chrome/browser/ui/views/tabs/tab_strip.h"
14 #include "chrome/browser/ui/views/toolbar_view.h" 15 #include "chrome/browser/ui/views/toolbar_view.h"
15 #include "chrome/common/url_constants.h" 16 #include "chrome/common/url_constants.h"
16 #include "chrome/test/base/in_process_browser_test.h" 17 #include "chrome/test/base/in_process_browser_test.h"
17 #include "chrome/test/base/ui_test_utils.h" 18 #include "chrome/test/base/ui_test_utils.h"
19 #include "ui/views/controls/single_split_view.h"
20 #include "ui/views/controls/webview/webview.h"
18 #include "ui/views/focus/focus_manager.h" 21 #include "ui/views/focus/focus_manager.h"
22 #include "ui/views/window/non_client_view.h"
19 23
20 using views::FocusManager; 24 using views::FocusManager;
21 25
26 namespace {
27
28 // Tab strip bounds depend on the window frame sizes.
29 gfx::Point ExpectedTabStripOrigin(BrowserView* browser_view) {
30 gfx::Rect tabstrip_bounds(
31 browser_view->frame()->GetBoundsForTabStrip(browser_view->tabstrip()));
32 gfx::Point tabstrip_origin(tabstrip_bounds.origin());
33 views::View::ConvertPointToTarget(browser_view->parent(),
34 browser_view,
35 &tabstrip_origin);
36 return tabstrip_origin;
37 }
38
39 }
40
22 typedef InProcessBrowserTest BrowserViewTest; 41 typedef InProcessBrowserTest BrowserViewTest;
23 42
24 IN_PROC_BROWSER_TEST_F(BrowserViewTest, BrowserView) { 43 IN_PROC_BROWSER_TEST_F(BrowserViewTest, BrowserView) {
25 BookmarkBarView::DisableAnimationsForTesting(true); 44 BookmarkBarView::DisableAnimationsForTesting(true);
26 45
27 BrowserView* browser_view = static_cast<BrowserView*>(browser()->window()); 46 BrowserView* browser_view = static_cast<BrowserView*>(browser()->window());
28 TopContainerView* top_container = browser_view->top_container(); 47 TopContainerView* top_container = browser_view->top_container();
48 TabStrip* tabstrip = browser_view->tabstrip();
49 ToolbarView* toolbar = browser_view->toolbar();
50 views::SingleSplitView* contents_split =
51 browser_view->GetContentsSplitForTest();
52 views::WebView* contents_container =
53 browser_view->GetContentsContainerForTest();
29 54
30 // Verify the view hierarchy. 55 // Verify the view hierarchy.
31 EXPECT_EQ(top_container, browser_view->tabstrip()->parent()); 56 EXPECT_EQ(top_container, browser_view->tabstrip()->parent());
32 EXPECT_EQ(top_container, browser_view->toolbar()->parent()); 57 EXPECT_EQ(top_container, browser_view->toolbar()->parent());
33 EXPECT_EQ(top_container, browser_view->GetBookmarkBarView()->parent()); 58 EXPECT_EQ(top_container, browser_view->GetBookmarkBarView()->parent());
34 EXPECT_EQ(browser_view, browser_view->infobar_container()->parent()); 59 EXPECT_EQ(browser_view, browser_view->infobar_container()->parent());
35 60
36 // Top container is at the front of the view hierarchy. 61 // Top container is at the front of the view hierarchy.
37 EXPECT_EQ(browser_view->child_count() - 1, 62 EXPECT_EQ(browser_view->child_count() - 1,
38 browser_view->GetIndexOf(top_container)); 63 browser_view->GetIndexOf(top_container));
39 64
40 // Verify basic layout. 65 // Verify basic layout.
41 EXPECT_EQ(0, top_container->x()); 66 EXPECT_EQ(0, top_container->x());
42 EXPECT_EQ(0, top_container->y()); 67 EXPECT_EQ(0, top_container->y());
43 EXPECT_EQ(browser_view->width(), top_container->width()); 68 EXPECT_EQ(browser_view->width(), top_container->width());
69 // Tabstrip layout varies based on window frame sizes.
70 gfx::Point expected_tabstrip_origin = ExpectedTabStripOrigin(browser_view);
71 EXPECT_EQ(expected_tabstrip_origin.x(), tabstrip->x());
72 EXPECT_EQ(expected_tabstrip_origin.y(), tabstrip->y());
73 EXPECT_EQ(0, toolbar->x());
74 EXPECT_EQ(
75 tabstrip->bounds().bottom() -
76 BrowserViewLayout::kToolbarTabStripVerticalOverlap,
77 toolbar->y());
78 EXPECT_EQ(0, contents_split->x());
79 EXPECT_EQ(toolbar->bounds().bottom(), contents_split->y());
80 EXPECT_EQ(0, contents_container->x());
81 EXPECT_EQ(0, contents_container->y());
44 82
45 // Verify bookmark bar visibility. 83 // Verify bookmark bar visibility.
46 BookmarkBarView* bookmark_bar = browser_view->GetBookmarkBarView(); 84 BookmarkBarView* bookmark_bar = browser_view->GetBookmarkBarView();
47 EXPECT_FALSE(bookmark_bar->visible()); 85 EXPECT_FALSE(bookmark_bar->visible());
48 EXPECT_FALSE(bookmark_bar->IsDetached()); 86 EXPECT_FALSE(bookmark_bar->IsDetached());
49 chrome::ExecuteCommand(browser(), IDC_SHOW_BOOKMARK_BAR); 87 chrome::ExecuteCommand(browser(), IDC_SHOW_BOOKMARK_BAR);
50 EXPECT_TRUE(bookmark_bar->visible()); 88 EXPECT_TRUE(bookmark_bar->visible());
51 EXPECT_FALSE(bookmark_bar->IsDetached()); 89 EXPECT_FALSE(bookmark_bar->IsDetached());
52 chrome::ExecuteCommand(browser(), IDC_SHOW_BOOKMARK_BAR); 90 chrome::ExecuteCommand(browser(), IDC_SHOW_BOOKMARK_BAR);
53 EXPECT_FALSE(bookmark_bar->visible()); 91 EXPECT_FALSE(bookmark_bar->visible());
54 EXPECT_FALSE(bookmark_bar->IsDetached()); 92 EXPECT_FALSE(bookmark_bar->IsDetached());
55 93
56 // Bookmark bar is reparented to BrowserView on NTP. 94 // Bookmark bar is reparented to BrowserView on NTP.
57 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); 95 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
58 EXPECT_TRUE(bookmark_bar->visible()); 96 EXPECT_TRUE(bookmark_bar->visible());
59 EXPECT_TRUE(bookmark_bar->IsDetached()); 97 EXPECT_TRUE(bookmark_bar->IsDetached());
60 EXPECT_EQ(browser_view, bookmark_bar->parent()); 98 EXPECT_EQ(browser_view, bookmark_bar->parent());
61 // Top container is still in front. 99 // Top container is still in front.
62 EXPECT_EQ(browser_view->child_count() - 1, 100 EXPECT_EQ(browser_view->child_count() - 1,
63 browser_view->GetIndexOf(top_container)); 101 browser_view->GetIndexOf(top_container));
64 102
103 // Bookmark bar layout on NTP.
104 EXPECT_EQ(0, bookmark_bar->x());
105 EXPECT_EQ(
106 tabstrip->bounds().bottom() +
107 toolbar->height() -
108 BrowserViewLayout::kToolbarTabStripVerticalOverlap -
109 views::NonClientFrameView::kClientEdgeThickness,
110 bookmark_bar->y());
111 EXPECT_EQ(toolbar->bounds().bottom(), contents_split->y());
112 // Contents have a "top margin" pushing them below the bookmark bar.
113 EXPECT_EQ(bookmark_bar->height() -
114 views::NonClientFrameView::kClientEdgeThickness,
115 contents_container->y());
116
65 // Bookmark bar is parented back to top container on normal page. 117 // Bookmark bar is parented back to top container on normal page.
66 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); 118 ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
67 EXPECT_FALSE(bookmark_bar->visible()); 119 EXPECT_FALSE(bookmark_bar->visible());
68 EXPECT_FALSE(bookmark_bar->IsDetached()); 120 EXPECT_FALSE(bookmark_bar->IsDetached());
69 EXPECT_EQ(top_container, bookmark_bar->parent()); 121 EXPECT_EQ(top_container, bookmark_bar->parent());
70 // Top container is still in front. 122 // Top container is still in front.
71 EXPECT_EQ(browser_view->child_count() - 1, 123 EXPECT_EQ(browser_view->child_count() - 1,
72 browser_view->GetIndexOf(top_container)); 124 browser_view->GetIndexOf(top_container));
73 125
74 BookmarkBarView::DisableAnimationsForTesting(false); 126 BookmarkBarView::DisableAnimationsForTesting(false);
(...skipping 13 matching lines...) Expand all
88 140
89 // Focus starts in the location bar or one of its children. 141 // Focus starts in the location bar or one of its children.
90 EXPECT_TRUE(location_bar_view->Contains(focus_manager->GetFocusedView())); 142 EXPECT_TRUE(location_bar_view->Contains(focus_manager->GetFocusedView()));
91 143
92 chrome::ToggleFullscreenMode(browser()); 144 chrome::ToggleFullscreenMode(browser());
93 EXPECT_TRUE(browser_view->IsFullscreen()); 145 EXPECT_TRUE(browser_view->IsFullscreen());
94 146
95 // Focus is released from the location bar. 147 // Focus is released from the location bar.
96 EXPECT_FALSE(location_bar_view->Contains(focus_manager->GetFocusedView())); 148 EXPECT_FALSE(location_bar_view->Contains(focus_manager->GetFocusedView()));
97 } 149 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698