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

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: maybe 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
« no previous file with comments | « ash/system/status_area_widget_delegate.cc ('k') | ash/system/tray/tray_background_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
32 SystemTray* GetSystemTray() { 31 SystemTray* GetSystemTray() {
33 return Shell::GetPrimaryRootWindowController()->shelf()-> 32 return Shell::GetPrimaryRootWindowController()->shelf()->
34 status_area_widget()->system_tray(); 33 status_area_widget()->system_tray();
35 } 34 }
36 35
37 // Trivial item implementation that tracks its views for testing. 36 // Trivial item implementation that tracks its views for testing.
38 class TestItem : public SystemTrayItem { 37 class TestItem : public SystemTrayItem {
39 public: 38 public:
40 TestItem() : SystemTrayItem(GetSystemTray()), tray_view_(NULL) {} 39 TestItem() : SystemTrayItem(GetSystemTray()), tray_view_(NULL) {}
41 40
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 EXPECT_EQ(widget, test_item->detailed_view()->GetWidget()); 287 EXPECT_EQ(widget, test_item->detailed_view()->GetWidget());
289 288
290 tray->ShowDefaultView(BUBBLE_USE_EXISTING); 289 tray->ShowDefaultView(BUBBLE_USE_EXISTING);
291 RunAllPendingInMessageLoop(); 290 RunAllPendingInMessageLoop();
292 291
293 EXPECT_EQ(bubble_bounds.ToString(), test_item->default_view()->GetWidget()-> 292 EXPECT_EQ(bubble_bounds.ToString(), test_item->default_view()->GetWidget()->
294 GetWindowBoundsInScreen().ToString()); 293 GetWindowBoundsInScreen().ToString());
295 EXPECT_EQ(widget, test_item->default_view()->GetWidget()); 294 EXPECT_EQ(widget, test_item->default_view()->GetWidget());
296 } 295 }
297 296
298 // Tests that the tray is laid out properly in the widget to make sure that the 297 // Tests that the tray is laid out properly and is fully contained within
299 // tray extends to the correct edge of the screen. 298 // the shelf.
300 TEST_F(SystemTrayTest, TrayBoundsInWidget) { 299 TEST_F(SystemTrayTest, TrayBoundsInWidget) {
300 internal::ShelfLayoutManager* manager =
301 Shell::GetPrimaryRootWindowController()->shelf()->shelf_layout_manager();
301 internal::StatusAreaWidget* widget = 302 internal::StatusAreaWidget* widget =
302 Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget(); 303 Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget();
303 SystemTray* tray = widget->system_tray(); 304 SystemTray* tray = widget->system_tray();
304 305
305 // Test in bottom alignment. Bottom and right edges of the view should be 306 // Test in bottom alignment.
306 // aligned with the widget. 307 manager->SetAlignment(SHELF_ALIGNMENT_BOTTOM);
307 widget->SetShelfAlignment(SHELF_ALIGNMENT_BOTTOM);
308 gfx::Rect window_bounds = widget->GetWindowBoundsInScreen(); 308 gfx::Rect window_bounds = widget->GetWindowBoundsInScreen();
309 gfx::Rect tray_bounds = tray->GetBoundsInScreen(); 309 gfx::Rect tray_bounds = tray->GetBoundsInScreen();
310 EXPECT_EQ(window_bounds.bottom(), 310 EXPECT_TRUE(window_bounds.bottom() >= tray_bounds.bottom());
311 tray_bounds.bottom() + kStatusTrayOffsetFromScreenEdgeForTest); 311 EXPECT_TRUE(window_bounds.right() >= tray_bounds.right());
312 EXPECT_EQ(window_bounds.right(), tray_bounds.right()); 312 EXPECT_TRUE(window_bounds.x() >= tray_bounds.x());
313 EXPECT_TRUE(window_bounds.y() >= tray_bounds.y());
313 314
314 // Test in the top alignment. Top and right edges should match. 315 // Test in the left alignment.
315 widget->SetShelfAlignment(SHELF_ALIGNMENT_TOP); 316 manager->SetAlignment(SHELF_ALIGNMENT_LEFT);
316 window_bounds = widget->GetWindowBoundsInScreen(); 317 window_bounds = widget->GetWindowBoundsInScreen();
317 tray_bounds = tray->GetBoundsInScreen(); 318 tray_bounds = tray->GetBoundsInScreen();
318 EXPECT_EQ(window_bounds.y(), 319 EXPECT_TRUE(window_bounds.bottom() >= tray_bounds.bottom());
319 tray_bounds.y() - kStatusTrayOffsetFromScreenEdgeForTest); 320 EXPECT_TRUE(window_bounds.right() >= tray_bounds.right());
320 EXPECT_EQ(window_bounds.right(), tray_bounds.right()); 321 EXPECT_TRUE(window_bounds.x() >= tray_bounds.x());
322 EXPECT_TRUE(window_bounds.y() >= tray_bounds.y());
321 323
322 // Test in the left alignment. Left and bottom edges should match. 324 // Test in the right alignment.
323 widget->SetShelfAlignment(SHELF_ALIGNMENT_LEFT); 325 manager->SetAlignment(SHELF_ALIGNMENT_LEFT);
324 window_bounds = widget->GetWindowBoundsInScreen(); 326 window_bounds = widget->GetWindowBoundsInScreen();
325 tray_bounds = tray->GetBoundsInScreen(); 327 tray_bounds = tray->GetBoundsInScreen();
326 EXPECT_EQ(window_bounds.bottom(), tray_bounds.bottom()); 328 EXPECT_TRUE(window_bounds.bottom() >= tray_bounds.bottom());
327 EXPECT_EQ(window_bounds.x(), 329 EXPECT_TRUE(window_bounds.right() >= tray_bounds.right());
328 tray_bounds.x() - kStatusTrayOffsetFromScreenEdgeForTest); 330 EXPECT_TRUE(window_bounds.x() >= tray_bounds.x());
329 331 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 } 332 }
337 333
338 } // namespace test 334 } // namespace test
339 } // namespace ash 335 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/status_area_widget_delegate.cc ('k') | ash/system/tray/tray_background_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698