| OLD | NEW |
| 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 "ash/common/shelf/shelf_layout_manager.h" | 5 #include "ash/common/shelf/shelf_layout_manager.h" |
| 6 #include "ash/common/shelf/wm_shelf.h" | 6 #include "ash/common/shelf/wm_shelf.h" |
| 7 #include "ash/common/wm_window.h" | 7 #include "ash/common/wm_window.h" |
| 8 #include "base/command_line.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_window.h" | 11 #include "chrome/browser/ui/browser_window.h" |
| 11 #include "chrome/browser/ui/status_bubble.h" | 12 #include "chrome/browser/ui/status_bubble.h" |
| 13 #include "chrome/common/chrome_switches.h" |
| 12 #include "chrome/test/base/in_process_browser_test.h" | 14 #include "chrome/test/base/in_process_browser_test.h" |
| 15 #include "chromeos/chromeos_switches.h" |
| 16 #include "components/user_manager/user_names.h" |
| 13 | 17 |
| 14 typedef InProcessBrowserTest ShelfBrowserTest; | 18 using ShelfBrowserTest = InProcessBrowserTest; |
| 15 | 19 |
| 16 // Confirm that a status bubble doesn't cause the shelf to darken. | 20 // Confirm that a status bubble doesn't cause the shelf to darken. |
| 17 IN_PROC_BROWSER_TEST_F(ShelfBrowserTest, StatusBubble) { | 21 IN_PROC_BROWSER_TEST_F(ShelfBrowserTest, StatusBubble) { |
| 18 ash::ShelfLayoutManager* shelf_layout_manager = | 22 ash::ShelfLayoutManager* shelf_layout_manager = |
| 19 ash::WmShelf::ForWindow( | 23 ash::WmShelf::ForWindow( |
| 20 ash::WmWindow::Get(browser()->window()->GetNativeWindow())) | 24 ash::WmWindow::Get(browser()->window()->GetNativeWindow())) |
| 21 ->shelf_layout_manager(); | 25 ->shelf_layout_manager(); |
| 22 EXPECT_TRUE(shelf_layout_manager->IsVisible()); | 26 EXPECT_TRUE(shelf_layout_manager->IsVisible()); |
| 23 | 27 |
| 24 // Ensure that the browser abuts the shelf. | 28 // Ensure that the browser abuts the shelf. |
| 25 gfx::Rect bounds = browser()->window()->GetBounds(); | 29 gfx::Rect bounds = browser()->window()->GetBounds(); |
| 26 bounds.set_height(shelf_layout_manager->GetIdealBounds().y() - bounds.y()); | 30 bounds.set_height(shelf_layout_manager->GetIdealBounds().y() - bounds.y()); |
| 27 browser()->window()->SetBounds(bounds); | 31 browser()->window()->SetBounds(bounds); |
| 28 EXPECT_FALSE(shelf_layout_manager->window_overlaps_shelf()); | 32 EXPECT_FALSE(shelf_layout_manager->window_overlaps_shelf()); |
| 29 | 33 |
| 30 // Show status, which may overlap the shelf by a pixel. | 34 // Show status, which may overlap the shelf by a pixel. |
| 31 browser()->window()->GetStatusBubble()->SetStatus( | 35 browser()->window()->GetStatusBubble()->SetStatus( |
| 32 base::UTF8ToUTF16("Dummy Status Text")); | 36 base::UTF8ToUTF16("Dummy Status Text")); |
| 33 shelf_layout_manager->UpdateVisibilityState(); | 37 shelf_layout_manager->UpdateVisibilityState(); |
| 34 | 38 |
| 35 // Ensure that status doesn't cause overlap. | 39 // Ensure that status doesn't cause overlap. |
| 36 EXPECT_FALSE(shelf_layout_manager->window_overlaps_shelf()); | 40 EXPECT_FALSE(shelf_layout_manager->window_overlaps_shelf()); |
| 37 | 41 |
| 38 // Ensure that moving the browser slightly down does cause overlap. | 42 // Ensure that moving the browser slightly down does cause overlap. |
| 39 bounds.Offset(0, 1); | 43 bounds.Offset(0, 1); |
| 40 browser()->window()->SetBounds(bounds); | 44 browser()->window()->SetBounds(bounds); |
| 41 EXPECT_TRUE(shelf_layout_manager->window_overlaps_shelf()); | 45 EXPECT_TRUE(shelf_layout_manager->window_overlaps_shelf()); |
| 42 } | 46 } |
| 47 |
| 48 class ShelfGuestSessionBrowserTest : public InProcessBrowserTest { |
| 49 protected: |
| 50 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 51 command_line->AppendSwitch(chromeos::switches::kGuestSession); |
| 52 command_line->AppendSwitch(::switches::kIncognito); |
| 53 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "hash"); |
| 54 command_line->AppendSwitchASCII( |
| 55 chromeos::switches::kLoginUser, |
| 56 user_manager::GuestAccountId().GetUserEmail()); |
| 57 } |
| 58 }; |
| 59 |
| 60 // Tests that in guest session, shelf alignment could be initialized to bottom |
| 61 // aligned, instead of bottom locked (crbug.com/699661). |
| 62 IN_PROC_BROWSER_TEST_F(ShelfGuestSessionBrowserTest, ShelfAlignment) { |
| 63 ash::WmShelf* shelf = ash::WmShelf::ForWindow( |
| 64 ash::WmWindow::Get(browser()->window()->GetNativeWindow())); |
| 65 EXPECT_EQ(ash::SHELF_ALIGNMENT_BOTTOM, shelf->alignment()); |
| 66 } |
| OLD | NEW |