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

Unified 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: added one test for immersive instant extended 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/frame/browser_view_browsertest.cc
diff --git a/chrome/browser/ui/views/frame/browser_view_browsertest.cc b/chrome/browser/ui/views/frame/browser_view_browsertest.cc
index 7600d44d693a735f247455943a1adc6c03b8917c..48e02996e8fdf970d06d146a2fc4915da8831dba 100644
--- a/chrome/browser/ui/views/frame/browser_view_browsertest.cc
+++ b/chrome/browser/ui/views/frame/browser_view_browsertest.cc
@@ -7,6 +7,8 @@
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
+#include "chrome/browser/ui/views/frame/browser_view_layout.h"
+#include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
#include "chrome/browser/ui/views/frame/top_container_view.h"
#include "chrome/browser/ui/views/infobars/infobar_container_view.h"
#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
@@ -15,10 +17,40 @@
#include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
+#include "ui/views/controls/single_split_view.h"
+#include "ui/views/controls/webview/webview.h"
#include "ui/views/focus/focus_manager.h"
+#include "ui/views/window/non_client_view.h"
+
+#if defined(OS_CHROMEOS)
+#include "chrome/browser/search/search.h"
+#include "chrome/browser/ui/search/instant_test_utils.h"
+#include "chrome/browser/ui/views/frame/contents_container.h"
+#include "ui/compositor/scoped_animation_duration_scale_mode.h"
+#endif
using views::FocusManager;
+namespace {
+
+// Tab strip bounds depend on the window frame sizes.
+gfx::Point ExpectedTabStripOrigin(BrowserView* browser_view) {
+ gfx::Rect tabstrip_bounds(
+ browser_view->frame()->GetBoundsForTabStrip(browser_view->tabstrip()));
+ gfx::Point tabstrip_origin(tabstrip_bounds.origin());
+ views::View::ConvertPointToTarget(browser_view->parent(),
+ browser_view,
+ &tabstrip_origin);
+ return tabstrip_origin;
+}
+
+// Returns the bounds of |view| in widget coordinates.
+gfx::Rect GetRectInWidget(views::View* view) {
+ return view->ConvertRectToWidget(view->GetLocalBounds());
+}
+
+}
+
typedef InProcessBrowserTest BrowserViewTest;
IN_PROC_BROWSER_TEST_F(BrowserViewTest, BrowserView) {
@@ -26,6 +58,12 @@ IN_PROC_BROWSER_TEST_F(BrowserViewTest, BrowserView) {
BrowserView* browser_view = static_cast<BrowserView*>(browser()->window());
TopContainerView* top_container = browser_view->top_container();
+ TabStrip* tabstrip = browser_view->tabstrip();
+ ToolbarView* toolbar = browser_view->toolbar();
+ views::SingleSplitView* contents_split =
+ browser_view->GetContentsSplitForTest();
+ views::WebView* contents_web_view =
+ browser_view->GetContentsWebViewForTest();
// Verify the view hierarchy.
EXPECT_EQ(top_container, browser_view->tabstrip()->parent());
@@ -41,6 +79,19 @@ IN_PROC_BROWSER_TEST_F(BrowserViewTest, BrowserView) {
EXPECT_EQ(0, top_container->x());
EXPECT_EQ(0, top_container->y());
EXPECT_EQ(browser_view->width(), top_container->width());
+ // Tabstrip layout varies based on window frame sizes.
+ gfx::Point expected_tabstrip_origin = ExpectedTabStripOrigin(browser_view);
+ EXPECT_EQ(expected_tabstrip_origin.x(), tabstrip->x());
+ EXPECT_EQ(expected_tabstrip_origin.y(), tabstrip->y());
+ EXPECT_EQ(0, toolbar->x());
+ EXPECT_EQ(
+ tabstrip->bounds().bottom() -
+ BrowserViewLayout::kToolbarTabStripVerticalOverlap,
+ toolbar->y());
+ EXPECT_EQ(0, contents_split->x());
+ EXPECT_EQ(toolbar->bounds().bottom(), contents_split->y());
+ EXPECT_EQ(0, contents_web_view->x());
+ EXPECT_EQ(0, contents_web_view->y());
// Verify bookmark bar visibility.
BookmarkBarView* bookmark_bar = browser_view->GetBookmarkBarView();
@@ -62,6 +113,20 @@ IN_PROC_BROWSER_TEST_F(BrowserViewTest, BrowserView) {
EXPECT_EQ(browser_view->child_count() - 1,
browser_view->GetIndexOf(top_container));
+ // Bookmark bar layout on NTP.
+ EXPECT_EQ(0, bookmark_bar->x());
+ EXPECT_EQ(
+ tabstrip->bounds().bottom() +
+ toolbar->height() -
+ BrowserViewLayout::kToolbarTabStripVerticalOverlap -
+ views::NonClientFrameView::kClientEdgeThickness,
+ bookmark_bar->y());
+ EXPECT_EQ(toolbar->bounds().bottom(), contents_split->y());
+ // Contents view has a "top margin" pushing it below the bookmark bar.
+ EXPECT_EQ(bookmark_bar->height() -
+ views::NonClientFrameView::kClientEdgeThickness,
+ contents_web_view->y());
+
// Bookmark bar is parented back to top container on normal page.
ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
EXPECT_FALSE(bookmark_bar->visible());
@@ -95,3 +160,78 @@ IN_PROC_BROWSER_TEST_F(BrowserViewTest, MAYBE_FullscreenClearsFocus) {
// Focus is released from the location bar.
EXPECT_FALSE(location_bar_view->Contains(focus_manager->GetFocusedView()));
}
+
+//////////////////////////////////////////////////////////////////////////////
+
+// Immersive fullscreen is currently enabled only on Chrome OS.
+#if defined(OS_CHROMEOS)
+
+class BrowserViewImmersiveInstantExtendedTest : public InProcessBrowserTest,
+ public InstantTestBase {
+ public:
+ BrowserViewImmersiveInstantExtendedTest() {}
+ virtual ~BrowserViewImmersiveInstantExtendedTest() {}
+
+ virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
+ chrome::EnableImmersiveFullscreenForTest();
+ chrome::EnableInstantExtendedAPIForTesting();
+ ASSERT_TRUE(https_test_server().Start());
+ GURL instant_url = https_test_server().GetURL(
+ "files/instant_extended.html?strk=1&");
+ InstantTestBase::Init(instant_url);
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(BrowserViewImmersiveInstantExtendedTest);
+};
+
+IN_PROC_BROWSER_TEST_F(BrowserViewImmersiveInstantExtendedTest,
+ ImmersiveInstantExtended) {
+ ui::ScopedAnimationDurationScaleMode zero_duration_mode(
+ ui::ScopedAnimationDurationScaleMode::ZERO_DURATION);
+ BookmarkBarView::DisableAnimationsForTesting(true);
+
+ // Cache some pointers we'll need below.
+ BrowserView* browser_view = static_cast<BrowserView*>(browser()->window());
+ ToolbarView* toolbar = browser_view->toolbar();
+
+ // Start up both instant and immersive fullscreen.
+ ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
+ ASSERT_TRUE(chrome::UseImmersiveFullscreen());
+ chrome::ToggleFullscreenMode(browser());
+ ASSERT_TRUE(browser_view->IsFullscreen());
+ ASSERT_TRUE(browser_view->immersive_mode_controller()->IsEnabled());
+
+ // Focus omnibox, which constructs an overlay web contents.
+ FocusOmniboxAndWaitForInstantExtendedSupport();
+ EXPECT_TRUE(instant()->model()->mode().is_default());
+ // The above testing code doesn't trigger the views location bar focus path,
+ // so force it to happen explicitly.
+ browser_view->SetFocusToLocationBar(false);
+ EXPECT_TRUE(browser_view->immersive_mode_controller()->IsRevealed());
+ // Content area is immediately below the tab indicators.
+ views::WebView* contents_web_view =
+ browser_view->GetContentsWebViewForTest();
+ EXPECT_EQ(GetRectInWidget(browser_view).y() + Tab::GetImmersiveHeight(),
+ GetRectInWidget(contents_web_view).y());
+
+ // Typing in the omnibox should show suggestions in an overlay view.
+ SetOmniboxTextAndWaitForOverlayToShow("query");
+ EXPECT_TRUE(instant()->model()->mode().is_search_suggestions());
+ // Content area is still immediately below the tab indicators.
+ EXPECT_EQ(GetRectInWidget(browser_view).y() + Tab::GetImmersiveHeight(),
+ GetRectInWidget(contents_web_view).y());
+ // Overlay web view (with suggestions) aligns with the bottom of the omnibox.
+ gfx::Rect overlay_rect_in_widget = GetRectInWidget(
+ browser_view->GetContentsContainerForTest()->GetOverlayWebViewForTest());
+ EXPECT_EQ(GetRectInWidget(toolbar).bottom(), overlay_rect_in_widget.y());
+
+ // TODO(jamescook): Add a test similar to InstantExtendedTest
+ // EscapeClearsOmnibox that navigates to NTP, does a search that puts
+ // suggestions in the active contents, then checks active web contents
+ // location.
+
+ BookmarkBarView::DisableAnimationsForTesting(false);
+}
+
+#endif // defined(OS_CHROMEOS)

Powered by Google App Engine
This is Rietveld 408576698