| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 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 | 7 |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "window_manager/callback.h" | 9 #include "window_manager/callback.h" |
| 10 #include "window_manager/event_loop.h" | 10 #include "window_manager/event_loop.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 &event_loop, | 32 &event_loop, |
| 33 NewPermanentCallback(&counter, &TestCallbackCounter::Increment), | 33 NewPermanentCallback(&counter, &TestCallbackCounter::Increment), |
| 34 100); | 34 100); |
| 35 coalescer.set_synchronous(true); | 35 coalescer.set_synchronous(true); |
| 36 | 36 |
| 37 coalescer.Start(); | 37 coalescer.Start(); |
| 38 EXPECT_EQ(0, counter.num_calls()); | 38 EXPECT_EQ(0, counter.num_calls()); |
| 39 | 39 |
| 40 // We used to initialize the positions to (0, 0) instead of (-1, -1), so | 40 // We used to initialize the positions to (0, 0) instead of (-1, -1), so |
| 41 // we'd incorrectly ignore initial (0, 0) values. | 41 // we'd incorrectly ignore initial (0, 0) values. |
| 42 coalescer.StorePosition(0, 0); | 42 coalescer.StorePosition(Point(0, 0)); |
| 43 EXPECT_EQ(1, counter.num_calls()); | 43 EXPECT_EQ(1, counter.num_calls()); |
| 44 EXPECT_EQ(0, coalescer.x()); | 44 EXPECT_EQ(0, coalescer.x()); |
| 45 EXPECT_EQ(0, coalescer.y()); | 45 EXPECT_EQ(0, coalescer.y()); |
| 46 | 46 |
| 47 coalescer.StorePosition(200, 300); | 47 coalescer.StorePosition(Point(200, 300)); |
| 48 EXPECT_EQ(2, counter.num_calls()); | 48 EXPECT_EQ(2, counter.num_calls()); |
| 49 EXPECT_EQ(200, coalescer.x()); | 49 EXPECT_EQ(200, coalescer.x()); |
| 50 EXPECT_EQ(300, coalescer.y()); | 50 EXPECT_EQ(300, coalescer.y()); |
| 51 | 51 |
| 52 coalescer.Stop(); | 52 coalescer.Stop(); |
| 53 EXPECT_EQ(2, counter.num_calls()); | 53 EXPECT_EQ(2, counter.num_calls()); |
| 54 | 54 |
| 55 coalescer.Start(); | 55 coalescer.Start(); |
| 56 EXPECT_EQ(2, counter.num_calls()); | 56 EXPECT_EQ(2, counter.num_calls()); |
| 57 | 57 |
| 58 // We should still notify if the first values that we receive after | 58 // We should still notify if the first values that we receive after |
| 59 // restarting matched the last ones that we saw before. | 59 // restarting matched the last ones that we saw before. |
| 60 coalescer.StorePosition(200, 300); | 60 coalescer.StorePosition(Point(200, 300)); |
| 61 EXPECT_EQ(3, counter.num_calls()); | 61 EXPECT_EQ(3, counter.num_calls()); |
| 62 EXPECT_EQ(200, coalescer.x()); | 62 EXPECT_EQ(200, coalescer.x()); |
| 63 EXPECT_EQ(300, coalescer.y()); | 63 EXPECT_EQ(300, coalescer.y()); |
| 64 } | 64 } |
| 65 | 65 |
| 66 } // namespace window_manager | 66 } // namespace window_manager |
| 67 | 67 |
| 68 int main(int argc, char** argv) { | 68 int main(int argc, char** argv) { |
| 69 return window_manager::InitAndRunTests(&argc, argv, &FLAGS_logtostderr); | 69 return window_manager::InitAndRunTests(&argc, argv, &FLAGS_logtostderr); |
| 70 } | 70 } |
| OLD | NEW |