Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/screen_layout_observer.h" | 5 #include "ash/system/screen_layout_observer.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/strings/grit/ash_strings.h" | 8 #include "ash/strings/grit/ash_strings.h" |
| 9 #include "ash/system/devicetype_utils.h" | 9 #include "ash/system/devicetype_utils.h" |
| 10 #include "ash/system/tray/system_tray.h" | 10 #include "ash/system/tray/system_tray.h" |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 423 display::DisplayPlacement::LEFT, 0); | 423 display::DisplayPlacement::LEFT, 0); |
| 424 display_manager()->SetLayoutForCurrentDisplays(builder.Build()); | 424 display_manager()->SetLayoutForCurrentDisplays(builder.Build()); |
| 425 EXPECT_TRUE(GetDisplayNotificationText().empty()); | 425 EXPECT_TRUE(GetDisplayNotificationText().empty()); |
| 426 | 426 |
| 427 // Close the lid. We go to docked mode, but we show no notifications. | 427 // Close the lid. We go to docked mode, but we show no notifications. |
| 428 UpdateDisplay("400x400"); | 428 UpdateDisplay("400x400"); |
| 429 EXPECT_TRUE(GetDisplayNotificationText().empty()); | 429 EXPECT_TRUE(GetDisplayNotificationText().empty()); |
| 430 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty()); | 430 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty()); |
| 431 } | 431 } |
| 432 | 432 |
| 433 // Tests that rotation notifications are only shown when the rotation source is | |
| 434 // a user action. The accelerometer source nevber produces any notifications. | |
| 435 TEST_F(ScreenLayoutObserverTest, RotationNotification) { | |
| 436 Shell::Get()->screen_layout_observer()->set_show_notifications_for_testing( | |
| 437 true); | |
| 438 UpdateDisplay("400x400"); | |
| 439 const int64_t primary_id = | |
| 440 display_manager()->GetPrimaryDisplayCandidate().id(); | |
| 441 display::ManagedDisplayInfo display_info(primary_id, "" /* name */, | |
| 442 true /* has_overscan */); | |
| 443 display::DisplayInfoList display_info_list; | |
| 444 display_info_list.emplace_back(display_info); | |
| 445 | |
| 446 // The accelerometer source. | |
| 447 display_info_list.back().Copy(display_manager()->GetDisplayInfo(primary_id)); | |
| 448 display_info_list.back().SetRotation( | |
| 449 display::Display::ROTATE_90, | |
| 450 display::Display::ROTATION_SOURCE_ACCELEROMETER); | |
| 451 display_manager()->OnNativeDisplaysChanged(display_info_list); | |
| 452 display_manager()->UpdateInternalManagedDisplayModeListForTest(); | |
|
oshima
2017/05/03 12:54:56
Can you use DisplayManager::SetDisplayRotation ?
afakhry
2017/05/03 16:02:41
Done.
| |
| 453 EXPECT_TRUE(GetDisplayNotificationText().empty()); | |
| 454 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty()); | |
| 455 | |
| 456 // The user source. | |
| 457 display_info_list.back().SetRotation(display::Display::ROTATE_180, | |
| 458 display::Display::ROTATION_SOURCE_USER); | |
| 459 display_manager()->OnNativeDisplaysChanged(display_info_list); | |
| 460 display_manager()->UpdateInternalManagedDisplayModeListForTest(); | |
| 461 EXPECT_EQ(l10n_util::GetStringFUTF16( | |
| 462 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED, GetFirstDisplayName(), | |
| 463 l10n_util::GetStringUTF16( | |
| 464 IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_180)), | |
| 465 GetDisplayNotificationAdditionalText()); | |
| 466 EXPECT_TRUE(GetDisplayNotificationText().empty()); | |
| 467 } | |
| 468 | |
| 433 } // namespace ash | 469 } // namespace ash |
| OLD | NEW |