[go: nahoru, domu]

blob: 5074b7b476756d5f8895ab9d57ab47fc4c446b41 [file] [log] [blame]
Alex Price36eacc0b2022-02-16 15:39:211// Copyright 2022 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "ash/public/cpp/system/toast_data.h"
6
7#include <string>
8#include <utility>
9
10#include "base/time/time.h"
11#include "testing/gtest/include/gtest/gtest.h"
12
13namespace ash {
14
15TEST(ToastDataTest, InitializedWithProvidedValues) {
16 ToastData data = ToastData(
17 /*id=*/"some_id", ToastCatalogName::kDebugCommand, /*text=*/u"some_text",
18 base::Seconds(1),
19 /*visible_on_lock_screen=*/true,
20 /*dismiss_text=*/u"Dismiss now");
21
22 EXPECT_EQ(data.id, "some_id");
23 EXPECT_EQ(data.catalog_name, ash::ToastCatalogName::kDebugCommand);
24 EXPECT_EQ(data.text, u"some_text");
25 EXPECT_EQ(data.duration, base::Seconds(1));
26 EXPECT_EQ(data.visible_on_lock_screen, true);
27 EXPECT_EQ(data.dismiss_text, u"Dismiss now");
28}
29
30TEST(ToastDataTest, InitializedWithDefaultValues) {
31 ToastData data = ToastData(
32 /*id=*/"some_id", ToastCatalogName::kDebugCommand, /*text=*/u"some_text");
33
34 EXPECT_EQ(data.duration, ToastData::kDefaultToastDuration);
35 EXPECT_EQ(data.visible_on_lock_screen, false);
36 EXPECT_EQ(data.dismiss_text, absl::nullopt);
37}
38
39TEST(ToastDataTest, InitializedWithInfiniteDuration) {
40 ToastData data = ToastData(
41 /*id=*/"some_id", ToastCatalogName::kDebugCommand, /*text=*/u"some_text",
42 ToastData::kInfiniteDuration);
43
44 EXPECT_EQ(data.duration, ToastData::kInfiniteDuration);
45}
46
47TEST(ToastDataTest, EnforcesMinimumDuration) {
48 ToastData data = ToastData(
49 /*id=*/"some_id", ToastCatalogName::kDebugCommand, /*text=*/u"some_text",
50 base::Milliseconds(1));
51
52 EXPECT_EQ(data.duration, ToastData::kMinimumDuration);
53}
54
55} // namespace ash