Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/ui/views/toolbar/reload_button.h" | |
|
sky
2017/02/28 20:11:52
newline between 5/6 (see style guide for details).
kylix_rd
2017/03/01 17:33:27
Interesting... this was changed by git cl format,
kylix_rd
2017/03/01 17:33:27
Done.
| |
| 5 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
| 6 #include "chrome/browser/ui/views/toolbar/reload_button.h" | |
| 7 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 7 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 8 #include "chrome/test/base/testing_profile.h" | 8 #include "chrome/test/base/testing_profile.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/events/event_utils.h" | 10 #include "ui/events/event_utils.h" |
| 11 #include "ui/views/test/test_views_delegate.h" | |
| 11 | 12 |
| 12 class ReloadButtonTest : public ChromeRenderViewHostTestHarness { | 13 class ReloadButtonTest : public ChromeRenderViewHostTestHarness { |
| 13 public: | 14 public: |
| 14 ReloadButtonTest(); | 15 ReloadButtonTest(); |
| 15 | 16 |
| 16 void CheckState(bool enabled, | 17 void CheckState(bool enabled, |
| 17 ReloadButton::Mode intended_mode, | 18 ReloadButton::Mode intended_mode, |
| 18 ReloadButton::Mode visible_mode, | 19 ReloadButton::Mode visible_mode, |
| 19 bool double_click_timer_running, | 20 bool double_click_timer_running, |
| 20 bool stop_to_reload_timer_running); | 21 bool stop_to_reload_timer_running); |
| 21 | 22 |
| 22 // These accessors eliminate the need to declare each testcase as a friend. | 23 // These accessors eliminate the need to declare each testcase as a friend. |
| 23 void set_mouse_hovered(bool hovered) { | 24 void set_mouse_hovered(bool hovered) { |
| 24 reload_.testing_mouse_hovered_ = hovered; | 25 reload_.testing_mouse_hovered_ = hovered; |
| 25 } | 26 } |
| 26 int reload_count() { return reload_.testing_reload_count_; } | 27 int reload_count() { return reload_.testing_reload_count_; } |
| 27 | 28 |
| 29 private: | |
|
sky
2017/02/28 20:11:52
Style guide says private section should be last (a
kylix_rd
2017/03/01 17:33:27
It seems that there is a chicken-and-egg problem t
Peter Kasting
2017/03/01 23:32:23
I was gonna leave a comment about how this test re
| |
| 30 views::TestViewsDelegate views_delegate_; | |
| 31 | |
| 28 protected: | 32 protected: |
| 29 ReloadButton reload_; | 33 ReloadButton reload_; |
| 30 }; | 34 }; |
|
Peter Kasting
2017/03/01 06:32:36
Nit: DISALLOW_COPY_AND_ASSIGN
kylix_rd
2017/03/01 17:33:27
Done.
| |
| 31 | 35 |
| 32 ReloadButtonTest::ReloadButtonTest() : reload_(profile(), nullptr) { | 36 ReloadButtonTest::ReloadButtonTest() : reload_(profile(), nullptr) { |
| 33 // Set the timer delays to 0 so that timers will fire as soon as we tell the | 37 // Set the timer delays to 0 so that timers will fire as soon as we tell the |
| 34 // message loop to run pending tasks. | 38 // message loop to run pending tasks. |
| 35 reload_.double_click_timer_delay_ = base::TimeDelta(); | 39 reload_.double_click_timer_delay_ = base::TimeDelta(); |
| 36 reload_.stop_to_reload_timer_delay_ = base::TimeDelta(); | 40 reload_.stop_to_reload_timer_delay_ = base::TimeDelta(); |
| 37 } | 41 } |
| 38 | 42 |
| 39 void ReloadButtonTest::CheckState(bool enabled, | 43 void ReloadButtonTest::CheckState(bool enabled, |
| 40 ReloadButton::Mode intended_mode, | 44 ReloadButton::Mode intended_mode, |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 reload_.ButtonPressed(&reload_, e); | 151 reload_.ButtonPressed(&reload_, e); |
| 148 reload_.ChangeMode(ReloadButton::MODE_STOP, false); | 152 reload_.ChangeMode(ReloadButton::MODE_STOP, false); |
| 149 set_mouse_hovered(true); | 153 set_mouse_hovered(true); |
| 150 reload_.ChangeMode(ReloadButton::MODE_RELOAD, false); | 154 reload_.ChangeMode(ReloadButton::MODE_RELOAD, false); |
| 151 | 155 |
| 152 // Now fire the stop-to-reload timer. This should reset the button. | 156 // Now fire the stop-to-reload timer. This should reset the button. |
| 153 base::RunLoop().RunUntilIdle(); | 157 base::RunLoop().RunUntilIdle(); |
| 154 CheckState(true, ReloadButton::MODE_RELOAD, ReloadButton::MODE_RELOAD, false, | 158 CheckState(true, ReloadButton::MODE_RELOAD, ReloadButton::MODE_RELOAD, false, |
| 155 false); | 159 false); |
| 156 } | 160 } |
| OLD | NEW |