| 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: |
| (...skipping 23 matching lines...) Expand all Loading... |
| 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 } |
| 38 | 38 |
| 39 void ReloadButtonTest::CheckState(bool enabled, | 39 void ReloadButtonTest::CheckState(bool enabled, |
| 40 ReloadButton::Mode intended_mode, | 40 ReloadButton::Mode intended_mode, |
| 41 ReloadButton::Mode visible_mode, | 41 ReloadButton::Mode visible_mode, |
| 42 bool double_click_timer_running, | 42 bool double_click_timer_running, |
| 43 bool stop_to_reload_timer_running) { | 43 bool stop_to_reload_timer_running) { |
| 44 EXPECT_EQ(enabled, reload_.IsEnabled()); | 44 EXPECT_EQ(enabled, reload_.enabled()); |
| 45 EXPECT_EQ(intended_mode, reload_.intended_mode_); | 45 EXPECT_EQ(intended_mode, reload_.intended_mode_); |
| 46 EXPECT_EQ(visible_mode, reload_.visible_mode_); | 46 EXPECT_EQ(visible_mode, reload_.visible_mode_); |
| 47 EXPECT_EQ(double_click_timer_running, | 47 EXPECT_EQ(double_click_timer_running, |
| 48 reload_.double_click_timer_.IsRunning()); | 48 reload_.double_click_timer_.IsRunning()); |
| 49 EXPECT_EQ(stop_to_reload_timer_running, | 49 EXPECT_EQ(stop_to_reload_timer_running, |
| 50 reload_.stop_to_reload_timer_.IsRunning()); | 50 reload_.stop_to_reload_timer_.IsRunning()); |
| 51 } | 51 } |
| 52 | 52 |
| 53 TEST_F(ReloadButtonTest, Basic) { | 53 TEST_F(ReloadButtonTest, Basic) { |
| 54 // The stop/reload button starts in the "enabled reload" state with no timers | 54 // The stop/reload button starts in the "enabled reload" state with no timers |
| (...skipping 86 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_.RunAllPending(); | 147 loop_.RunAllPending(); |
| 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 |