1c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 2c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// found in the LICENSE file. 4c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 5c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chrome/browser/ui/views/frame/browser_view.h" 6c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "chrome/app/chrome_command_ids.h" 890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "chrome/browser/ui/browser_commands.h" 990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" 1090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "chrome/browser/ui/views/frame/browser_view_layout.h" 114e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#include "chrome/browser/ui/views/frame/test_with_browser_view.h" 1290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "chrome/browser/ui/views/frame/top_container_view.h" 1390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "chrome/browser/ui/views/infobars/infobar_container_view.h" 1490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "chrome/browser/ui/views/tabs/tab_strip.h" 15f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "chrome/browser/ui/views/toolbar/toolbar_view.h" 1690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "chrome/common/url_constants.h" 1790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "ui/views/controls/single_split_view.h" 1890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "ui/views/controls/webview/webview.h" 19c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 2090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)namespace { 2190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 2290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Tab strip bounds depend on the window frame sizes. 2390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)gfx::Point ExpectedTabStripOrigin(BrowserView* browser_view) { 2490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gfx::Rect tabstrip_bounds( 2590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) browser_view->frame()->GetBoundsForTabStrip(browser_view->tabstrip())); 2690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gfx::Point tabstrip_origin(tabstrip_bounds.origin()); 2790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) views::View::ConvertPointToTarget(browser_view->parent(), 2890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) browser_view, 2990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) &tabstrip_origin); 3090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) return tabstrip_origin; 3190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} 3290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 3390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} // namespace 3490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 354e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)typedef TestWithBrowserView BrowserViewTest; 367d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 37c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Test basic construction and initialization. 38c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)TEST_F(BrowserViewTest, BrowserView) { 39c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // The window is owned by the native widget, not the test class. 40c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_FALSE(window()); 414e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 42c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_TRUE(browser_view()->browser()); 43c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 44c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Test initial state. 45c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_TRUE(browser_view()->IsTabStripVisible()); 46c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_FALSE(browser_view()->IsOffTheRecord()); 47c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_FALSE(browser_view()->IsGuestSession()); 48c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_FALSE(browser_view()->ShouldShowAvatar()); 49c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_TRUE(browser_view()->IsBrowserTypeNormal()); 50c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_FALSE(browser_view()->IsFullscreen()); 51c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_FALSE(browser_view()->IsBookmarkBarVisible()); 52c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_FALSE(browser_view()->IsBookmarkBarAnimating()); 5390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} 5490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 5590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Test layout of the top-of-window UI. 5690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)TEST_F(BrowserViewTest, BrowserViewLayout) { 5790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) BookmarkBarView::DisableAnimationsForTesting(true); 5890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 5990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // |browser_view_| owns the Browser, not the test class. 6090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) Browser* browser = browser_view()->browser(); 6190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) TopContainerView* top_container = browser_view()->top_container(); 6290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) TabStrip* tabstrip = browser_view()->tabstrip(); 6390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) ToolbarView* toolbar = browser_view()->toolbar(); 645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) views::View* contents_container = 655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) browser_view()->GetContentsContainerForTest(); 6690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) views::WebView* contents_web_view = 6790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) browser_view()->GetContentsWebViewForTest(); 685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) views::WebView* devtools_web_view = 695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) browser_view()->GetDevToolsWebViewForTest(); 7090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 7190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Start with a single tab open to a normal page. 7290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) AddTab(browser, GURL("about:blank")); 7390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 7490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Verify the view hierarchy. 7590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) EXPECT_EQ(top_container, browser_view()->tabstrip()->parent()); 7690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) EXPECT_EQ(top_container, browser_view()->toolbar()->parent()); 7790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) EXPECT_EQ(top_container, browser_view()->GetBookmarkBarView()->parent()); 7890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) EXPECT_EQ(browser_view(), browser_view()->infobar_container()->parent()); 7990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 80ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // Find bar host is at the front of the view hierarchy, followed by the top 81ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // container. 8290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) EXPECT_EQ(browser_view()->child_count() - 1, 83868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) browser_view()->GetIndexOf(browser_view()->find_bar_host_view())); 84ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch EXPECT_EQ(browser_view()->child_count() - 2, 8590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) browser_view()->GetIndexOf(top_container)); 8690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 8790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Verify basic layout. 8890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) EXPECT_EQ(0, top_container->x()); 8990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) EXPECT_EQ(0, top_container->y()); 9090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) EXPECT_EQ(browser_view()->width(), top_container->width()); 9190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Tabstrip layout varies based on window frame sizes. 9290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) gfx::Point expected_tabstrip_origin = ExpectedTabStripOrigin(browser_view()); 9390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) EXPECT_EQ(expected_tabstrip_origin.x(), tabstrip->x()); 9490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) EXPECT_EQ(expected_tabstrip_origin.y(), tabstrip->y()); 9590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) EXPECT_EQ(0, toolbar->x()); 9690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) EXPECT_EQ( 9790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) tabstrip->bounds().bottom() - 9890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) BrowserViewLayout::kToolbarTabStripVerticalOverlap, 9990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) toolbar->y()); 1005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(0, contents_container->x()); 1015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(toolbar->bounds().bottom(), contents_container->y()); 1025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(top_container->bounds().bottom(), contents_container->y()); 1035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(0, devtools_web_view->x()); 1045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(0, devtools_web_view->y()); 10590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) EXPECT_EQ(0, contents_web_view->x()); 10690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) EXPECT_EQ(0, contents_web_view->y()); 10790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 10890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Verify bookmark bar visibility. 10990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) BookmarkBarView* bookmark_bar = browser_view()->GetBookmarkBarView(); 11090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) EXPECT_FALSE(bookmark_bar->visible()); 11190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) EXPECT_FALSE(bookmark_bar->IsDetached()); 11290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) chrome::ExecuteCommand(browser, IDC_SHOW_BOOKMARK_BAR); 11390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) EXPECT_TRUE(bookmark_bar->visible()); 11490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) EXPECT_FALSE(bookmark_bar->IsDetached()); 11590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) chrome::ExecuteCommand(browser, IDC_SHOW_BOOKMARK_BAR); 11690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) EXPECT_FALSE(bookmark_bar->visible()); 11790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) EXPECT_FALSE(bookmark_bar->IsDetached()); 11890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 11990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Bookmark bar is reparented to BrowserView on NTP. 12090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) NavigateAndCommitActiveTabWithTitle(browser, 12190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) GURL(chrome::kChromeUINewTabURL), 122a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) base::string16()); 12390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) EXPECT_TRUE(bookmark_bar->visible()); 12490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) EXPECT_TRUE(bookmark_bar->IsDetached()); 12590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) EXPECT_EQ(browser_view(), bookmark_bar->parent()); 126ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // Find bar host is still at the front of the view hierarchy, followed by 127ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // the top container. 12890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) EXPECT_EQ(browser_view()->child_count() - 1, 129868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) browser_view()->GetIndexOf(browser_view()->find_bar_host_view())); 130ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch EXPECT_EQ(browser_view()->child_count() - 2, 13190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) browser_view()->GetIndexOf(top_container)); 13290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 13390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Bookmark bar layout on NTP. 13490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) EXPECT_EQ(0, bookmark_bar->x()); 13590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) EXPECT_EQ( 13690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) tabstrip->bounds().bottom() + 13790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) toolbar->height() - 13890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) BrowserViewLayout::kToolbarTabStripVerticalOverlap - 13990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) views::NonClientFrameView::kClientEdgeThickness, 14090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) bookmark_bar->y()); 1415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(toolbar->bounds().bottom(), contents_container->y()); 14290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Contents view has a "top margin" pushing it below the bookmark bar. 14390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) EXPECT_EQ(bookmark_bar->height() - 14490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) views::NonClientFrameView::kClientEdgeThickness, 1455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) devtools_web_view->y()); 1465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(bookmark_bar->height() - 1475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) views::NonClientFrameView::kClientEdgeThickness, 14890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) contents_web_view->y()); 14990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 15090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Bookmark bar is parented back to top container on normal page. 15190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) NavigateAndCommitActiveTabWithTitle(browser, 15290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) GURL("about:blank"), 153a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) base::string16()); 15490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) EXPECT_FALSE(bookmark_bar->visible()); 15590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) EXPECT_FALSE(bookmark_bar->IsDetached()); 15690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) EXPECT_EQ(top_container, bookmark_bar->parent()); 157ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch // Top container is still second from front. 158ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch EXPECT_EQ(browser_view()->child_count() - 2, 15990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) browser_view()->GetIndexOf(top_container)); 160c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 16190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) BookmarkBarView::DisableAnimationsForTesting(false); 162c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} 1637d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 1645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class BrowserViewHostedAppTest : public TestWithBrowserView { 1655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public: 1665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) BrowserViewHostedAppTest() 1675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) : TestWithBrowserView(Browser::TYPE_POPUP, 1685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) chrome::HOST_DESKTOP_TYPE_NATIVE, 1695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) true) { 1705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 1715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual ~BrowserViewHostedAppTest() { 1725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 1735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) private: 1755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(BrowserViewHostedAppTest); 1765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}; 1775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Test basic layout for hosted apps. 1795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)TEST_F(BrowserViewHostedAppTest, Layout) { 1805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Add a tab because the browser starts out without any tabs at all. 1815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) AddTab(browser(), GURL("about:blank")); 1825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) views::View* contents_container = 1845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) browser_view()->GetContentsContainerForTest(); 1855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // The tabstrip, toolbar and bookmark bar should not be visible for hosted 1875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // apps. 1885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_FALSE(browser_view()->tabstrip()->visible()); 1895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_FALSE(browser_view()->toolbar()->visible()); 1905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_FALSE(browser_view()->IsBookmarkBarVisible()); 1915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) gfx::Point header_offset; 1935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) views::View::ConvertPointToTarget( 1945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) browser_view(), 1955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) browser_view()->frame()->non_client_view()->frame_view(), 1965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) &header_offset); 1975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // The position of the bottom of the header (the bar with the window 1995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // controls) in the coordinates of BrowserView. 2005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int bottom_of_header = browser_view()->frame()->GetTopInset() - 2015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) header_offset.y(); 2025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // The web contents should be flush with the bottom of the header. 2045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(bottom_of_header, contents_container->y()); 2055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // The find bar should overlap the 1px header/web-contents separator at the 2075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // bottom of the header. 2085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) EXPECT_EQ(browser_view()->frame()->GetTopInset() - 1, 2095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) browser_view()->GetFindBarBoundingBox().y()); 2105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 211