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

Side by Side Diff: ash/system/tray/system_tray_unittest.cc

Issue 23928004: ash:Shelf - Update position and hit box of status area. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 3 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 "ash/system/tray/system_tray.h" 5 #include "ash/system/tray/system_tray.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/root_window_controller.h" 9 #include "ash/root_window_controller.h"
10 #include "ash/shelf/shelf_layout_manager.h"
10 #include "ash/shelf/shelf_widget.h" 11 #include "ash/shelf/shelf_widget.h"
11 #include "ash/shell.h" 12 #include "ash/shell.h"
12 #include "ash/system/status_area_widget.h" 13 #include "ash/system/status_area_widget.h"
13 #include "ash/system/tray/system_tray_item.h" 14 #include "ash/system/tray/system_tray_item.h"
14 #include "ash/test/ash_test_base.h" 15 #include "ash/test/ash_test_base.h"
15 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
16 #include "ui/views/controls/label.h" 17 #include "ui/views/controls/label.h"
17 #include "ui/views/layout/fill_layout.h" 18 #include "ui/views/layout/fill_layout.h"
18 #include "ui/views/view.h" 19 #include "ui/views/view.h"
19 #include "ui/views/widget/widget.h" 20 #include "ui/views/widget/widget.h"
20 21
21 #if defined(OS_WIN) 22 #if defined(OS_WIN)
22 #include "base/win/windows_version.h" 23 #include "base/win/windows_version.h"
23 #endif 24 #endif
24 25
25 namespace ash { 26 namespace ash {
26 namespace test { 27 namespace test {
27 28
28 namespace { 29 namespace {
29 30
30 const int kStatusTrayOffsetFromScreenEdgeForTest = 4; 31 const int kStatusTrayOffsetFromScreenEdgeForTest = 4;
James Cook 2013/09/18 01:36:07 Is this needed any more?
31 32
32 SystemTray* GetSystemTray() { 33 SystemTray* GetSystemTray() {
33 return Shell::GetPrimaryRootWindowController()->shelf()-> 34 return Shell::GetPrimaryRootWindowController()->shelf()->
34 status_area_widget()->system_tray(); 35 status_area_widget()->system_tray();
35 } 36 }
36 37
37 // Trivial item implementation that tracks its views for testing. 38 // Trivial item implementation that tracks its views for testing.
38 class TestItem : public SystemTrayItem { 39 class TestItem : public SystemTrayItem {
39 public: 40 public:
40 TestItem() : SystemTrayItem(GetSystemTray()), tray_view_(NULL) {} 41 TestItem() : SystemTrayItem(GetSystemTray()), tray_view_(NULL) {}
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 EXPECT_EQ(widget, test_item->detailed_view()->GetWidget()); 289 EXPECT_EQ(widget, test_item->detailed_view()->GetWidget());
289 290
290 tray->ShowDefaultView(BUBBLE_USE_EXISTING); 291 tray->ShowDefaultView(BUBBLE_USE_EXISTING);
291 RunAllPendingInMessageLoop(); 292 RunAllPendingInMessageLoop();
292 293
293 EXPECT_EQ(bubble_bounds.ToString(), test_item->default_view()->GetWidget()-> 294 EXPECT_EQ(bubble_bounds.ToString(), test_item->default_view()->GetWidget()->
294 GetWindowBoundsInScreen().ToString()); 295 GetWindowBoundsInScreen().ToString());
295 EXPECT_EQ(widget, test_item->default_view()->GetWidget()); 296 EXPECT_EQ(widget, test_item->default_view()->GetWidget());
296 } 297 }
297 298
298 // Tests that the tray is laid out properly in the widget to make sure that the 299 // Tests that the tray is laid out properly and is fully contained within
299 // tray extends to the correct edge of the screen. 300 // the shelf.
300 TEST_F(SystemTrayTest, TrayBoundsInWidget) { 301 TEST_F(SystemTrayTest, TrayBoundsInWidget) {
302 internal::ShelfLayoutManager* manager =
303 Shell::GetPrimaryRootWindowController()->shelf()->shelf_layout_manager();
301 internal::StatusAreaWidget* widget = 304 internal::StatusAreaWidget* widget =
302 Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget(); 305 Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget();
303 SystemTray* tray = widget->system_tray(); 306 SystemTray* tray = widget->system_tray();
304 307
305 // Test in bottom alignment. Bottom and right edges of the view should be 308 // Test in bottom alignment.
306 // aligned with the widget. 309 manager->SetAlignment(SHELF_ALIGNMENT_BOTTOM);
307 widget->SetShelfAlignment(SHELF_ALIGNMENT_BOTTOM);
308 gfx::Rect window_bounds = widget->GetWindowBoundsInScreen(); 310 gfx::Rect window_bounds = widget->GetWindowBoundsInScreen();
309 gfx::Rect tray_bounds = tray->GetBoundsInScreen(); 311 gfx::Rect tray_bounds = tray->GetBoundsInScreen();
310 EXPECT_EQ(window_bounds.bottom(), 312 EXPECT_TRUE(window_bounds.bottom() >= tray_bounds.bottom());
311 tray_bounds.bottom() + kStatusTrayOffsetFromScreenEdgeForTest); 313 EXPECT_TRUE(window_bounds.right() >= tray_bounds.right());
312 EXPECT_EQ(window_bounds.right(), tray_bounds.right()); 314 EXPECT_TRUE(window_bounds.x() >= tray_bounds.x());
315 EXPECT_TRUE(window_bounds.y() >= tray_bounds.y());
313 316
314 // Test in the top alignment. Top and right edges should match. 317 // Test in the left alignment.
315 widget->SetShelfAlignment(SHELF_ALIGNMENT_TOP); 318 manager->SetAlignment(SHELF_ALIGNMENT_LEFT);
316 window_bounds = widget->GetWindowBoundsInScreen(); 319 window_bounds = widget->GetWindowBoundsInScreen();
317 tray_bounds = tray->GetBoundsInScreen(); 320 tray_bounds = tray->GetBoundsInScreen();
318 EXPECT_EQ(window_bounds.y(), 321 EXPECT_TRUE(window_bounds.bottom() >= tray_bounds.bottom());
319 tray_bounds.y() - kStatusTrayOffsetFromScreenEdgeForTest); 322 EXPECT_TRUE(window_bounds.right() >= tray_bounds.right());
320 EXPECT_EQ(window_bounds.right(), tray_bounds.right()); 323 EXPECT_TRUE(window_bounds.x() >= tray_bounds.x());
324 EXPECT_TRUE(window_bounds.y() >= tray_bounds.y());
321 325
322 // Test in the left alignment. Left and bottom edges should match. 326 // Test in the right alignment.
323 widget->SetShelfAlignment(SHELF_ALIGNMENT_LEFT); 327 manager->SetAlignment(SHELF_ALIGNMENT_LEFT);
324 window_bounds = widget->GetWindowBoundsInScreen(); 328 window_bounds = widget->GetWindowBoundsInScreen();
325 tray_bounds = tray->GetBoundsInScreen(); 329 tray_bounds = tray->GetBoundsInScreen();
326 EXPECT_EQ(window_bounds.bottom(), tray_bounds.bottom()); 330 EXPECT_TRUE(window_bounds.bottom() >= tray_bounds.bottom());
327 EXPECT_EQ(window_bounds.x(), 331 EXPECT_TRUE(window_bounds.right() >= tray_bounds.right());
328 tray_bounds.x() - kStatusTrayOffsetFromScreenEdgeForTest); 332 EXPECT_TRUE(window_bounds.x() >= tray_bounds.x());
329 333 EXPECT_TRUE(window_bounds.y() >= tray_bounds.y());
330 // Test in the right alignment. Right and bottom edges should match.
331 widget->SetShelfAlignment(SHELF_ALIGNMENT_LEFT);
332 window_bounds = widget->GetWindowBoundsInScreen();
333 tray_bounds = tray->GetBoundsInScreen();
334 EXPECT_EQ(window_bounds.bottom(), tray_bounds.bottom());
335 EXPECT_EQ(window_bounds.right(), tray_bounds.right());
336 } 334 }
337 335
338 } // namespace test 336 } // namespace test
339 } // namespace ash 337 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698