Chromium Code Reviews| 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/system/web_notification/web_notification_tray.h" | 5 #include "ash/common/system/web_notification/web_notification_tray.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/common/shelf/shelf_layout_manager.h" | |
| 10 #include "ash/common/shelf/wm_shelf.h" | 11 #include "ash/common/shelf/wm_shelf.h" |
| 11 #include "ash/common/shell_window_ids.h" | 12 #include "ash/common/shell_window_ids.h" |
| 12 #include "ash/common/system/status_area_widget.h" | 13 #include "ash/common/system/status_area_widget.h" |
| 13 #include "ash/common/system/tray/system_tray.h" | 14 #include "ash/common/system/tray/system_tray.h" |
| 14 #include "ash/common/system/tray/system_tray_item.h" | 15 #include "ash/common/system/tray/system_tray_item.h" |
| 15 #include "ash/common/system/web_notification/ash_popup_alignment_delegate.h" | 16 #include "ash/common/system/web_notification/ash_popup_alignment_delegate.h" |
| 16 #include "ash/common/wm/window_state.h" | 17 #include "ash/common/wm/window_state.h" |
| 17 #include "ash/common/wm_lookup.h" | 18 #include "ash/common/wm_lookup.h" |
| 18 #include "ash/common/wm_window.h" | 19 #include "ash/common/wm_window.h" |
| 19 #include "ash/display/display_manager.h" | 20 #include "ash/display/display_manager.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 return tray->popup_alignment_delegate_->GetWorkAreaBottom(); | 141 return tray->popup_alignment_delegate_->GetWorkAreaBottom(); |
| 141 } | 142 } |
| 142 | 143 |
| 143 bool IsPopupVisible() { return GetTray()->IsPopupVisible(); } | 144 bool IsPopupVisible() { return GetTray()->IsPopupVisible(); } |
| 144 | 145 |
| 145 static std::unique_ptr<views::Widget> CreateTestWidget() { | 146 static std::unique_ptr<views::Widget> CreateTestWidget() { |
| 146 return AshTestBase::CreateTestWidget( | 147 return AshTestBase::CreateTestWidget( |
| 147 nullptr, kShellWindowId_DefaultContainer, gfx::Rect(1, 2, 3, 4)); | 148 nullptr, kShellWindowId_DefaultContainer, gfx::Rect(1, 2, 3, 4)); |
| 148 } | 149 } |
| 149 | 150 |
| 151 static void UpdateAutoHideStateNow() { | |
| 152 GetPrimaryShelf()->shelf_layout_manager()->UpdateAutoHideStateNow(); | |
| 153 } | |
| 154 | |
| 150 private: | 155 private: |
| 151 DISALLOW_COPY_AND_ASSIGN(WebNotificationTrayTest); | 156 DISALLOW_COPY_AND_ASSIGN(WebNotificationTrayTest); |
| 152 }; | 157 }; |
| 153 | 158 |
| 154 TEST_F(WebNotificationTrayTest, WebNotifications) { | 159 TEST_F(WebNotificationTrayTest, WebNotifications) { |
| 155 // TODO(mukai): move this test case to ui/message_center. | 160 // TODO(mukai): move this test case to ui/message_center. |
| 156 ASSERT_TRUE(GetWidget()); | 161 ASSERT_TRUE(GetWidget()); |
| 157 | 162 |
| 158 // Add a notification. | 163 // Add a notification. |
| 159 AddNotification("test_id1"); | 164 AddNotification("test_id1"); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 363 widget.reset(); | 368 widget.reset(); |
| 364 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); | 369 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
| 365 int bottom_auto_shown = GetPopupWorkAreaBottom(); | 370 int bottom_auto_shown = GetPopupWorkAreaBottom(); |
| 366 EXPECT_EQ(bottom, bottom_auto_shown); | 371 EXPECT_EQ(bottom, bottom_auto_shown); |
| 367 | 372 |
| 368 // Create the system tray during auto-hide. | 373 // Create the system tray during auto-hide. |
| 369 widget = CreateTestWidget(); | 374 widget = CreateTestWidget(); |
| 370 TestItem* test_item = new TestItem; | 375 TestItem* test_item = new TestItem; |
| 371 GetSystemTray()->AddTrayItem(test_item); | 376 GetSystemTray()->AddTrayItem(test_item); |
| 372 GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW); | 377 GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW); |
| 378 UpdateAutoHideStateNow(); | |
|
James Cook
2016/09/22 21:17:17
Would it work to call shelf->UpdateAutoHideState()
oshima
2016/09/23 09:37:20
This is to deal with timer delay, not posted event
| |
| 373 | 379 |
| 374 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); | 380 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
| 375 EXPECT_TRUE(GetTray()->IsPopupVisible()); | 381 EXPECT_TRUE(GetTray()->IsPopupVisible()); |
| 376 int bottom_with_tray = GetPopupWorkAreaBottom(); | 382 int bottom_with_tray = GetPopupWorkAreaBottom(); |
| 377 EXPECT_GT(bottom_auto_shown, bottom_with_tray); | 383 EXPECT_GT(bottom_auto_shown, bottom_with_tray); |
| 378 | 384 |
| 379 // Create tray notification. | 385 // Create tray notification. |
| 380 GetSystemTray()->ShowNotificationView(test_item); | 386 GetSystemTray()->ShowNotificationView(test_item); |
| 381 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); | 387 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
| 382 int bottom_with_tray_notification = GetPopupWorkAreaBottom(); | 388 int bottom_with_tray_notification = GetPopupWorkAreaBottom(); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 523 ui::ET_TOUCH_RELEASED, out_of_bounds, touch_id, | 529 ui::ET_TOUCH_RELEASED, out_of_bounds, touch_id, |
| 524 move.time_stamp() + base::TimeDelta::FromMilliseconds(50)); | 530 move.time_stamp() + base::TimeDelta::FromMilliseconds(50)); |
| 525 generator.Dispatch(&release); | 531 generator.Dispatch(&release); |
| 526 EXPECT_FALSE(tray->draw_background_as_active()); | 532 EXPECT_FALSE(tray->draw_background_as_active()); |
| 527 EXPECT_FALSE(tray->IsMessageCenterBubbleVisible()); | 533 EXPECT_FALSE(tray->IsMessageCenterBubbleVisible()); |
| 528 } | 534 } |
| 529 | 535 |
| 530 #endif // OS_CHROMEOS | 536 #endif // OS_CHROMEOS |
| 531 | 537 |
| 532 } // namespace ash | 538 } // namespace ash |
| OLD | NEW |