OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 | 6 |
7 #import "chrome/browser/cocoa/reload_button.h" | 7 #import "chrome/browser/cocoa/reload_button.h" |
8 | 8 |
9 #include "base/scoped_nsobject.h" | 9 #include "base/scoped_nsobject.h" |
10 #include "chrome/app/chrome_dll_resource.h" | 10 #include "chrome/app/chrome_dll_resource.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 TEST_F(ReloadButtonTest, StopAfterReloadSet) { | 147 TEST_F(ReloadButtonTest, StopAfterReloadSet) { |
148 id mock_target = [OCMockObject mockForProtocol:@protocol(TargetActionMock)]; | 148 id mock_target = [OCMockObject mockForProtocol:@protocol(TargetActionMock)]; |
149 [button_ setTarget:mock_target]; | 149 [button_ setTarget:mock_target]; |
150 [button_ setAction:@selector(anAction:)]; | 150 [button_ setAction:@selector(anAction:)]; |
151 | 151 |
152 EXPECT_FALSE([button_ isMouseInside]); | 152 EXPECT_FALSE([button_ isMouseInside]); |
153 | 153 |
154 // Get to stop mode. | 154 // Get to stop mode. |
155 [button_ setIsLoading:YES force:YES]; | 155 [button_ setIsLoading:YES force:YES]; |
156 EXPECT_EQ([button_ tag], IDC_STOP); | 156 EXPECT_EQ([button_ tag], IDC_STOP); |
| 157 EXPECT_TRUE([button_ isEnabled]); |
157 | 158 |
158 // Expect the action once. | 159 // Expect the action once. |
159 [[mock_target expect] anAction:button_]; | 160 [[mock_target expect] anAction:button_]; |
160 | 161 |
161 // Clicking in stop mode should send the action and transition to | 162 // Clicking in stop mode should send the action and transition to |
162 // reload mode. | 163 // reload mode. |
163 const std::pair<NSEvent*,NSEvent*> click = | 164 const std::pair<NSEvent*,NSEvent*> click = |
164 test_event_utils::MouseClickInView(button_, 1); | 165 test_event_utils::MouseClickInView(button_, 1); |
165 [NSApp postEvent:click.second atStart:YES]; | 166 [NSApp postEvent:click.second atStart:YES]; |
166 [button_ mouseDown:click.first]; | 167 [button_ mouseDown:click.first]; |
167 EXPECT_EQ([button_ tag], IDC_RELOAD); | 168 EXPECT_EQ([button_ tag], IDC_RELOAD); |
| 169 EXPECT_TRUE([button_ isEnabled]); |
168 | 170 |
169 // Get back to stop mode. | 171 // Get back to stop mode. |
170 [button_ setIsLoading:YES force:YES]; | 172 [button_ setIsLoading:YES force:YES]; |
171 EXPECT_EQ([button_ tag], IDC_STOP); | 173 EXPECT_EQ([button_ tag], IDC_STOP); |
| 174 EXPECT_TRUE([button_ isEnabled]); |
172 | 175 |
173 // If hover prevented reload mode immediately taking effect, clicks | 176 // If hover prevented reload mode immediately taking effect, clicks should do |
174 // should not send any action, but should still transition to reload | 177 // nothing, because the button should be disabled. |
175 // mode. | |
176 [button_ mouseEntered:nil]; | 178 [button_ mouseEntered:nil]; |
177 EXPECT_TRUE([button_ isMouseInside]); | 179 EXPECT_TRUE([button_ isMouseInside]); |
178 [button_ setIsLoading:NO force:NO]; | 180 [button_ setIsLoading:NO force:NO]; |
179 EXPECT_EQ([button_ tag], IDC_STOP); | 181 EXPECT_EQ([button_ tag], IDC_STOP); |
| 182 EXPECT_FALSE([button_ isEnabled]); |
180 [NSApp postEvent:click.second atStart:YES]; | 183 [NSApp postEvent:click.second atStart:YES]; |
181 [button_ mouseDown:click.first]; | 184 [button_ mouseDown:click.first]; |
182 EXPECT_EQ([button_ tag], IDC_RELOAD); | 185 EXPECT_EQ([button_ tag], IDC_STOP); |
183 | 186 |
184 [button_ setTarget:nil]; | 187 [button_ setTarget:nil]; |
185 } | 188 } |
186 | 189 |
187 } // namespace | 190 } // namespace |
OLD | NEW |