~townsend/unity/fix-lp1301394-trusty

« back to all changes in this revision

Viewing changes to tests/test_session_button.cpp

  • Committer: Marco Trevisan (Treviño)
  • Date: 2013-03-19 14:54:43 UTC
  • mto: This revision was merged to the branch mainline in revision 3230.
  • Revision ID: mail@3v1n0.net-20130319145443-haj17upx757zifq2
TestSessionButtonTypes: added typed tests for action buttons

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
 
47
47
TEST_F(TestSessionButton, Construct)
48
48
{
 
49
  EXPECT_EQ(button.action(), Button::Action::LOCK);
49
50
  EXPECT_FALSE(button.highlighted());
50
51
  EXPECT_TRUE(button.AcceptKeyNavFocusOnMouseEnter());
51
52
  EXPECT_FALSE(button.AcceptKeyNavFocusOnMouseDown());
119
120
  EXPECT_TRUE(activated);
120
121
}
121
122
 
122
 
// Other tests
123
 
 
124
 
TEST(TestSessionButtonLabel, Lock)
125
 
{
126
 
  Button button(Button::Action::LOCK);
127
 
  EXPECT_EQ(button.label(), "Lock");
128
 
}
129
 
 
130
 
TEST(TestSessionButtonLabel, Logout)
131
 
{
132
 
  Button button(Button::Action::LOGOUT);
133
 
  EXPECT_EQ(button.label(), "Log Out");
134
 
}
135
 
 
136
 
TEST(TestSessionButtonLabel, Suspend)
137
 
{
138
 
  Button button(Button::Action::SUSPEND);
139
 
  EXPECT_EQ(button.label(), "Suspend");
140
 
}
141
 
 
142
 
TEST(TestSessionButtonLabel, Hibernate)
143
 
{
144
 
  Button button(Button::Action::HIBERNATE);
145
 
  EXPECT_EQ(button.label(), "Hibernate");
146
 
}
147
 
 
148
 
TEST(TestSessionButtonLabel, Reboot)
149
 
{
150
 
  Button button(Button::Action::REBOOT);
151
 
  EXPECT_EQ(button.label(), "Restart");
152
 
}
153
 
 
154
 
TEST(TestSessionButtonLabel, Shutdown)
155
 
{
156
 
  Button button(Button::Action::SHUTDOWN);
157
 
  EXPECT_EQ(button.label(), "Shut Down");
 
123
// Action typed buttons tests
 
124
 
 
125
struct ActionButton : public testing::TestWithParam<Button::Action> {
 
126
  ActionButton()
 
127
    : button(GetParam())
 
128
  {}
 
129
 
 
130
  std::string GetExpectedLabel()
 
131
  {
 
132
    switch (GetParam())
 
133
    {
 
134
      case Button::Action::LOCK:
 
135
        return "Lock";
 
136
      case Button::Action::LOGOUT:
 
137
        return "Log Out";
 
138
      case Button::Action::SUSPEND:
 
139
        return "Suspend";
 
140
      case Button::Action::HIBERNATE:
 
141
        return "Hibernate";
 
142
      case Button::Action::SHUTDOWN:
 
143
        return "Shut Down";
 
144
      case Button::Action::REBOOT:
 
145
        return "Restart";
 
146
    }
 
147
 
 
148
    return "";
 
149
  }
 
150
 
 
151
  Button button;
 
152
};
 
153
 
 
154
INSTANTIATE_TEST_CASE_P(TestSessionButtonTypes, ActionButton,
 
155
  testing::Values(Button::Action::LOCK, Button::Action::LOGOUT, Button::Action::SUSPEND,
 
156
                  Button::Action::HIBERNATE, Button::Action::SHUTDOWN, Button::Action::REBOOT));
 
157
 
 
158
TEST_P(/*TestSessionButtonTypes*/ActionButton, Label)
 
159
{
 
160
  EXPECT_EQ(button.label(), GetExpectedLabel());
 
161
}
 
162
 
 
163
TEST_P(/*TestSessionButtonTypes*/ActionButton, Action)
 
164
{
 
165
  EXPECT_EQ(button.action(), GetParam());
158
166
}
159
167
 
160
168
} // session