OLD | NEW |
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium OS 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 <gflags/gflags.h> | 5 #include <gflags/gflags.h> |
6 #include <gtest/gtest.h> | 6 #include <gtest/gtest.h> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
12 #include "base/stl_util-inl.h" | 12 #include "base/stl_util-inl.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "chromeos/callback.h" | 14 #include "chromeos/callback.h" |
15 #include "chromeos/obsolete_logging.h" | 15 #include "chromeos/obsolete_logging.h" |
16 #include "window_manager/key_bindings.h" | 16 #include "window_manager/key_bindings.h" |
17 #include "window_manager/mock_x_connection.h" | 17 #include "window_manager/mock_x_connection.h" |
18 #include "window_manager/test_lib.h" | 18 #include "window_manager/test_lib.h" |
19 | 19 |
20 DEFINE_bool(logtostderr, false, | 20 DEFINE_bool(logtostderr, false, |
21 "Print debugging messages to stderr (suppressed otherwise)"); | 21 "Print debugging messages to stderr (suppressed otherwise)"); |
22 | 22 |
23 namespace chromeos { | 23 namespace window_manager { |
| 24 |
| 25 using chromeos::NewPermanentCallback; |
24 | 26 |
25 struct TestAction { | 27 struct TestAction { |
26 explicit TestAction(const std::string& name_param) | 28 explicit TestAction(const std::string& name_param) |
27 : name(name_param), | 29 : name(name_param), |
28 begin_call_count(0), | 30 begin_call_count(0), |
29 repeat_call_count(0), | 31 repeat_call_count(0), |
30 end_call_count(0) { | 32 end_call_count(0) { |
31 } | 33 } |
32 ~TestAction() { | 34 ~TestAction() { |
33 } | 35 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 use_end_closure ? | 87 use_end_closure ? |
86 NewPermanentCallback(action, &TestAction::EndCallback) : NULL); | 88 NewPermanentCallback(action, &TestAction::EndCallback) : NULL); |
87 } | 89 } |
88 | 90 |
89 void AddAllActions() { | 91 void AddAllActions() { |
90 for (int i = 0; i < kNumActions; ++i) { | 92 for (int i = 0; i < kNumActions; ++i) { |
91 AddAction(i, true, true, true); | 93 AddAction(i, true, true, true); |
92 } | 94 } |
93 } | 95 } |
94 | 96 |
95 scoped_ptr<chromeos::XConnection> xconn_; | 97 scoped_ptr<window_manager::XConnection> xconn_; |
96 scoped_ptr<chromeos::KeyBindings> bindings_; | 98 scoped_ptr<window_manager::KeyBindings> bindings_; |
97 std::vector<TestAction*> actions_; | 99 std::vector<TestAction*> actions_; |
98 | 100 |
99 static const int kNumActions = 10; | 101 static const int kNumActions = 10; |
100 }; | 102 }; |
101 | 103 |
102 TEST_F(KeyBindingTest, Basic) { | 104 TEST_F(KeyBindingTest, Basic) { |
103 // Action 0: Requests begin, end, and repeat callbacks. | 105 // Action 0: Requests begin, end, and repeat callbacks. |
104 AddAction(0, true, true, true); | 106 AddAction(0, true, true, true); |
105 bindings_->AddBinding(KeyBindings::KeyCombo(XK_e, KeyBindings::kControlMask), | 107 bindings_->AddBinding(KeyBindings::KeyCombo(XK_e, KeyBindings::kControlMask), |
106 actions_[0]->name); | 108 actions_[0]->name); |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 | 338 |
337 // Attempts to remove actions should fail (already removed). | 339 // Attempts to remove actions should fail (already removed). |
338 for (int i = 0; i < kNumActions; ++i) { | 340 for (int i = 0; i < kNumActions; ++i) { |
339 EXPECT_FALSE(bindings_->RemoveAction(actions_[i]->name)); | 341 EXPECT_FALSE(bindings_->RemoveAction(actions_[i]->name)); |
340 } | 342 } |
341 } | 343 } |
342 | 344 |
343 } // namespace | 345 } // namespace |
344 | 346 |
345 int main(int argc, char **argv) { | 347 int main(int argc, char **argv) { |
346 return chromeos::InitAndRunTests(&argc, argv, &FLAGS_logtostderr); | 348 return window_manager::InitAndRunTests(&argc, argv, &FLAGS_logtostderr); |
347 } | 349 } |
OLD | NEW |