| 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/display/display_manager.h" | 5 #include "ash/display/display_manager.h" |
| 6 #include "ash/screen_util.h" | 6 #include "ash/screen_util.h" |
| 7 #include "ash/shelf/shelf.h" | 7 #include "ash/shelf/shelf.h" |
| 8 #include "ash/shelf/shelf_layout_manager.h" | 8 #include "ash/shelf/shelf_layout_manager.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/system/toast/toast_manager.h" | 10 #include "ash/system/toast/toast_manager.h" |
| 11 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
| 12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 14 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 15 | 15 |
| 16 namespace ash { | 16 namespace ash { |
| 17 | 17 |
| 18 // Long duration so the timeout doesn't occur. | 18 // Long duration so the timeout doesn't occur. |
| 19 const int64_t kLongLongDuration = INT64_MAX; | 19 const int32_t kLongLongDuration = INT32_MAX; |
| 20 | 20 |
| 21 class DummyEvent : public ui::Event { | 21 class DummyEvent : public ui::Event { |
| 22 public: | 22 public: |
| 23 DummyEvent() : Event(ui::ET_UNKNOWN, base::TimeDelta(), 0) {} | 23 DummyEvent() : Event(ui::ET_UNKNOWN, base::TimeDelta(), 0) {} |
| 24 ~DummyEvent() override {} | 24 ~DummyEvent() override {} |
| 25 }; | 25 }; |
| 26 | 26 |
| 27 class ToastManagerTest : public test::AshTestBase { | 27 class ToastManagerTest : public test::AshTestBase { |
| 28 public: | 28 public: |
| 29 ToastManagerTest() {} | 29 ToastManagerTest() {} |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 } | 69 } |
| 70 | 70 |
| 71 void SetShelfState(ShelfVisibilityState state) { | 71 void SetShelfState(ShelfVisibilityState state) { |
| 72 Shelf::ForPrimaryDisplay()->shelf_layout_manager()->SetState(state); | 72 Shelf::ForPrimaryDisplay()->shelf_layout_manager()->SetState(state); |
| 73 } | 73 } |
| 74 | 74 |
| 75 void SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior) { | 75 void SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior) { |
| 76 Shelf::ForPrimaryDisplay()->SetAutoHideBehavior(behavior); | 76 Shelf::ForPrimaryDisplay()->SetAutoHideBehavior(behavior); |
| 77 } | 77 } |
| 78 | 78 |
| 79 std::string ShowToast(const std::string& text, uint64_t duration) { | 79 std::string ShowToast(const std::string& text, int32_t duration) { |
| 80 std::string id = "TOAST_ID_" + base::UintToString(serial_++); | 80 std::string id = "TOAST_ID_" + base::UintToString(serial_++); |
| 81 manager()->Show(ToastData(id, text, duration)); | 81 manager()->Show(ToastData(id, text, duration)); |
| 82 return id; | 82 return id; |
| 83 } | 83 } |
| 84 | 84 |
| 85 void CancelToast(const std::string& id) { manager()->Cancel(id); } | 85 void CancelToast(const std::string& id) { manager()->Cancel(id); } |
| 86 | 86 |
| 87 private: | 87 private: |
| 88 ToastManager* manager_ = nullptr; | 88 ToastManager* manager_ = nullptr; |
| 89 unsigned int serial_ = 0; | 89 unsigned int serial_ = 0; |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 EXPECT_EQ("TEXT3", GetCurrentText()); | 298 EXPECT_EQ("TEXT3", GetCurrentText()); |
| 299 // Cancel the shown toast. | 299 // Cancel the shown toast. |
| 300 CancelToast(id3); | 300 CancelToast(id3); |
| 301 // Confirm that the shown toast disappears. | 301 // Confirm that the shown toast disappears. |
| 302 EXPECT_FALSE(GetCurrentOverlay()); | 302 EXPECT_FALSE(GetCurrentOverlay()); |
| 303 // Confirm that only 1 toast is shown. | 303 // Confirm that only 1 toast is shown. |
| 304 EXPECT_EQ(2, GetToastSerial()); | 304 EXPECT_EQ(2, GetToastSerial()); |
| 305 } | 305 } |
| 306 | 306 |
| 307 } // namespace ash | 307 } // namespace ash |
| OLD | NEW |