OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium 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 "base/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "chrome/browser/ui/views/reload_button.h" | 6 #include "chrome/browser/ui/views/reload_button.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 class ReloadButtonTest : public testing::Test { | 9 class ReloadButtonTest : public testing::Test { |
10 public: | 10 public: |
11 ReloadButtonTest(); | 11 ReloadButtonTest(); |
12 | 12 |
13 void CheckState(bool enabled, | 13 void CheckState(bool enabled, |
14 ReloadButton::Mode intended_mode, | 14 ReloadButton::Mode intended_mode, |
15 ReloadButton::Mode visible_mode, | 15 ReloadButton::Mode visible_mode, |
16 bool double_click_timer_running, | 16 bool double_click_timer_running, |
17 bool stop_to_reload_timer_running); | 17 bool stop_to_reload_timer_running); |
18 | 18 |
19 // These accessors eliminate the need to declare each testcase as a friend. | 19 // These accessors eliminate the need to declare each testcase as a friend. |
20 void set_mouse_hovered(bool hovered) { | 20 void set_mouse_hovered(bool hovered) { |
21 reload_.testing_mouse_hovered_ = hovered; | 21 reload_.testing_mouse_hovered_ = hovered; |
22 } | 22 } |
23 int reload_count() { return reload_.testing_reload_count_; } | 23 int reload_count() { return reload_.testing_reload_count_; } |
24 | 24 |
25 protected: | 25 protected: |
26 // We need a message loop for the timers to post events. | 26 // We need a message loop for the timers to post events. |
27 MessageLoop loop_; | 27 base::MessageLoop loop_; |
28 | 28 |
29 ReloadButton reload_; | 29 ReloadButton reload_; |
30 }; | 30 }; |
31 | 31 |
32 ReloadButtonTest::ReloadButtonTest() : reload_(NULL, NULL) { | 32 ReloadButtonTest::ReloadButtonTest() : reload_(NULL, NULL) { |
33 // Set the timer delays to 0 so that timers will fire as soon as we tell the | 33 // Set the timer delays to 0 so that timers will fire as soon as we tell the |
34 // message loop to run pending tasks. | 34 // message loop to run pending tasks. |
35 reload_.double_click_timer_delay_ = base::TimeDelta(); | 35 reload_.double_click_timer_delay_ = base::TimeDelta(); |
36 reload_.stop_to_reload_timer_delay_ = base::TimeDelta(); | 36 reload_.stop_to_reload_timer_delay_ = base::TimeDelta(); |
37 } | 37 } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 reload_.ButtonPressed(&reload_, e); | 141 reload_.ButtonPressed(&reload_, e); |
142 reload_.ChangeMode(ReloadButton::MODE_STOP, false); | 142 reload_.ChangeMode(ReloadButton::MODE_STOP, false); |
143 set_mouse_hovered(true); | 143 set_mouse_hovered(true); |
144 reload_.ChangeMode(ReloadButton::MODE_RELOAD, false); | 144 reload_.ChangeMode(ReloadButton::MODE_RELOAD, false); |
145 | 145 |
146 // Now fire the stop-to-reload timer. This should reset the button. | 146 // Now fire the stop-to-reload timer. This should reset the button. |
147 loop_.RunUntilIdle(); | 147 loop_.RunUntilIdle(); |
148 CheckState(true, ReloadButton::MODE_RELOAD, ReloadButton::MODE_RELOAD, false, | 148 CheckState(true, ReloadButton::MODE_RELOAD, ReloadButton::MODE_RELOAD, false, |
149 false); | 149 false); |
150 } | 150 } |
OLD | NEW |