Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: ash/system/tray/tray_info_label_unittest.cc

Issue 2957043002: Add a row in the network tray to inform users to turn Bluetooth on to enable Tether. (Closed)
Patch Set: khorimoto@ and jamescook@ comments Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 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/system/tray/tray_info_label.h"
6 #include "ash/test/ash_test_base.h"
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 namespace ash {
10
11 namespace {
12
13 class TestEvent : public ui::Event {
Kyle Horimoto 2017/07/12 22:45:59 TestEvent --> TestClickEvent
lesliewatkins 2017/07/13 22:12:49 Done.
14 public:
15 TestEvent() : ui::Event(ui::ET_MOUSE_PRESSED, base::TimeTicks(), 0) {}
16 };
17
18 class TestNonClickableDelegate : public TrayInfoLabel::Delegate {
Kyle Horimoto 2017/07/12 22:45:59 Just make one TestDelegate class which can be set
lesliewatkins 2017/07/13 22:12:49 Done.
19 public:
20 void OnLabelClicked(int message_id) override {}
21
22 bool LabelIsClickable(int message_id) override { return false; }
23 };
24
25 class TestClickableDelegate : public TrayInfoLabel::Delegate {
26 public:
27 bool LabelWasClicked() { return was_clicked_; }
28
29 void OnLabelClicked(int message_id) override { was_clicked_ = true; }
30
31 bool LabelIsClickable(int message_id) override { return true; }
32
33 private:
34 bool was_clicked_ = false;
35 };
36
37 } // namespace
Kyle Horimoto 2017/07/12 22:45:59 nit: Newline after this.
lesliewatkins 2017/07/13 22:12:49 Done.
38 namespace test {
Kyle Horimoto 2017/07/12 22:45:59 Is there a reason why you're using this extra name
lesliewatkins 2017/07/13 22:12:48 I moved the test namespace up to the top. The anon
Kyle Horimoto 2017/07/13 23:15:36 Sorry I wasn't clear - I'm referring to the test n
lesliewatkins 2017/07/14 06:41:52 Done.
39
40 class TrayInfoLabelTest : public AshTestBase {
Kyle Horimoto 2017/07/12 22:45:59 Add instance variables (std::unique_ptr's) for bot
lesliewatkins 2017/07/13 22:12:48 Done.
41 public:
42 int LabelMessageId(TrayInfoLabel* label) { return label->message_id_; }
43
44 void ConfirmClickableLabel(TrayInfoLabel* label) {
45 EXPECT_TRUE(label->IsClickable());
46 }
47
48 void ConfirmNonClickableLabel(TrayInfoLabel* label) {
49 EXPECT_FALSE(label->IsClickable());
50 }
51 };
52
53 TEST_F(TrayInfoLabelTest, NoDelegate) {
54 TrayInfoLabel* label = new TrayInfoLabel(nullptr, 0);
55
56 ConfirmNonClickableLabel(label);
57 }
58
59 TEST_F(TrayInfoLabelTest, NonClickableDelegate) {
Kyle Horimoto 2017/07/12 22:45:59 For the tests with the delegate, call Update() wit
lesliewatkins 2017/07/13 22:12:48 That's what the Update test does.
Kyle Horimoto 2017/07/13 23:15:36 You just need to show that the correct values are
lesliewatkins 2017/07/14 06:41:51 I added the AX node stuff, but still not convinced
Kyle Horimoto 2017/07/14 17:54:21 Okay, that's fine! The a11y stuff was the bigger c
lesliewatkins 2017/07/14 20:43:16 Acknowledged.
60 TrayInfoLabel* label = new TrayInfoLabel(new TestNonClickableDelegate(), 0);
61
62 ConfirmNonClickableLabel(label);
63 }
64
65 TEST_F(TrayInfoLabelTest, ClickableDelegate) {
66 TrayInfoLabel* label = new TrayInfoLabel(new TestClickableDelegate(), 0);
67
68 ConfirmClickableLabel(label);
69 }
70
71 TEST_F(TrayInfoLabelTest, PerformAction) {
72 TestClickableDelegate* delegate = new TestClickableDelegate();
73 TrayInfoLabel* label = new TrayInfoLabel(delegate, 0);
74
75 ASSERT_FALSE(delegate->LabelWasClicked());
76
77 TestEvent event;
78 label->PerformAction(event);
79
80 EXPECT_TRUE(delegate->LabelWasClicked());
81 }
82
83 TEST_F(TrayInfoLabelTest, Update) {
84 TrayInfoLabel* label = new TrayInfoLabel(nullptr, 0);
85 ASSERT_EQ(LabelMessageId(label), 0);
86
87 label->Update(1);
88 EXPECT_EQ(LabelMessageId(label), 1);
89 }
90
91 } // namespace test
92 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698