OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/update/tray_update.h" | 5 #include "ash/system/update/tray_update.h" |
6 | 6 |
7 #include "ash/public/interfaces/update.mojom.h" | 7 #include "ash/public/interfaces/update.mojom.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/system/tray/system_tray.h" | 9 #include "ash/system/tray/system_tray.h" |
10 #include "ash/system/tray/system_tray_controller.h" | 10 #include "ash/system/tray/system_tray_controller.h" |
11 #include "ash/test/ash_test.h" | 11 #include "ash/test/ash_test.h" |
| 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "ui/events/event.h" |
| 14 #include "ui/views/controls/label.h" |
12 | 15 |
13 namespace ash { | 16 namespace ash { |
14 | 17 |
15 using TrayUpdateTest = AshTest; | 18 using TrayUpdateTest = AshTest; |
16 | 19 |
17 // Tests that the update icon becomes visible when an update becomes | 20 // Tests that the update icon becomes visible when an update becomes |
18 // available. | 21 // available. |
19 TEST_F(TrayUpdateTest, VisibilityAfterUpdate) { | 22 TEST_F(TrayUpdateTest, VisibilityAfterUpdate) { |
20 TrayUpdate* tray_update = GetPrimarySystemTray()->tray_update(); | 23 SystemTray* tray = GetPrimarySystemTray(); |
| 24 TrayUpdate* tray_update = tray->tray_update(); |
21 | 25 |
22 // The system starts with no update pending, so the icon isn't visible. | 26 // The system starts with no update pending, so the icon isn't visible. |
23 EXPECT_FALSE(tray_update->tray_view()->visible()); | 27 EXPECT_FALSE(tray_update->tray_view()->visible()); |
24 | 28 |
25 // Simulate an update. | 29 // Simulate an update. |
26 Shell::Get()->system_tray_controller()->ShowUpdateIcon( | 30 Shell::Get()->system_tray_controller()->ShowUpdateIcon( |
27 mojom::UpdateSeverity::LOW, false); | 31 mojom::UpdateSeverity::LOW, false, mojom::UpdateType::SYSTEM); |
28 | 32 |
29 // Tray item is now visible. | 33 // Tray item is now visible. |
30 EXPECT_TRUE(tray_update->tray_view()->visible()); | 34 EXPECT_TRUE(tray_update->tray_view()->visible()); |
| 35 |
| 36 tray->ShowDefaultView(BUBBLE_CREATE_NEW); |
| 37 base::string16 label = tray_update->GetLabelForTesting()->text(); |
| 38 EXPECT_EQ("Restart to update", base::UTF16ToUTF8(label)); |
| 39 } |
| 40 |
| 41 TEST_F(TrayUpdateTest, VisibilityAfterFlashUpdate) { |
| 42 SystemTray* tray = GetPrimarySystemTray(); |
| 43 TrayUpdate* tray_update = tray->tray_update(); |
| 44 |
| 45 // Simulate an update. |
| 46 Shell::Get()->system_tray_controller()->ShowUpdateIcon( |
| 47 mojom::UpdateSeverity::LOW, false, mojom::UpdateType::FLASH); |
| 48 |
| 49 // Tray item is now visible. |
| 50 EXPECT_TRUE(tray_update->tray_view()->visible()); |
| 51 |
| 52 tray->ShowDefaultView(BUBBLE_CREATE_NEW); |
| 53 base::string16 label = tray_update->GetLabelForTesting()->text(); |
| 54 EXPECT_EQ("Restart to update Adobe Flash Player", base::UTF16ToUTF8(label)); |
31 } | 55 } |
32 | 56 |
33 } // namespace ash | 57 } // namespace ash |
OLD | NEW |