| 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
| 8 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 8 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
| 9 #import "chrome/browser/ui/cocoa/gradient_button_cell.h" | 9 #import "chrome/browser/ui/cocoa/gradient_button_cell.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 [cell setShowsBorderOnlyWhileMouseInside:YES]; | 76 [cell setShowsBorderOnlyWhileMouseInside:YES]; |
| 77 [cell setShowsBorderOnlyWhileMouseInside:YES]; | 77 [cell setShowsBorderOnlyWhileMouseInside:YES]; |
| 78 [cell setShowsBorderOnlyWhileMouseInside:NO]; | 78 [cell setShowsBorderOnlyWhileMouseInside:NO]; |
| 79 [cell setShowsBorderOnlyWhileMouseInside:NO]; | 79 [cell setShowsBorderOnlyWhileMouseInside:NO]; |
| 80 } | 80 } |
| 81 | 81 |
| 82 TEST_F(GradientButtonCellTest, ContinuousPulseOnOff) { | 82 TEST_F(GradientButtonCellTest, ContinuousPulseOnOff) { |
| 83 GradientButtonCell* cell = [view_ cell]; | 83 GradientButtonCell* cell = [view_ cell]; |
| 84 | 84 |
| 85 // On/off | 85 // On/off |
| 86 EXPECT_FALSE([cell isContinuousPulsing]); | 86 EXPECT_FALSE([cell isPulseStuckOn]); |
| 87 [cell setIsContinuousPulsing:YES]; | 87 [cell setPulseIsStuckOn:YES]; |
| 88 EXPECT_TRUE([cell isContinuousPulsing]); | 88 EXPECT_TRUE([cell isPulseStuckOn]); |
| 89 EXPECT_TRUE([cell pulsing]); | 89 EXPECT_FALSE([cell pulsing]); |
| 90 [cell setIsContinuousPulsing:NO]; | 90 [cell setPulseIsStuckOn:NO]; |
| 91 EXPECT_FALSE([cell isContinuousPulsing]); | 91 EXPECT_FALSE([cell isPulseStuckOn]); |
| 92 | 92 |
| 93 // On/safeOff | 93 // On/safeOff |
| 94 [cell setIsContinuousPulsing:YES]; | 94 [cell setPulseIsStuckOn:YES]; |
| 95 EXPECT_TRUE([cell isContinuousPulsing]); | 95 EXPECT_TRUE([cell isPulseStuckOn]); |
| 96 [cell safelyStopPulsing]; | |
| 97 } | 96 } |
| 98 | 97 |
| 99 // More for valgrind; we don't confirm state change does anything useful. | 98 // More for valgrind; we don't confirm state change does anything useful. |
| 100 TEST_F(GradientButtonCellTest, PulseState) { | 99 TEST_F(GradientButtonCellTest, PulseState) { |
| 101 GradientButtonCell* cell = [view_ cell]; | 100 GradientButtonCell* cell = [view_ cell]; |
| 102 | 101 |
| 103 [cell setMouseInside:YES animate:YES]; | 102 [cell setMouseInside:YES animate:YES]; |
| 104 // Allow for immediate state changes to keep test unflaky | 103 // Allow for immediate state changes to keep test unflaky |
| 105 EXPECT_TRUE(([cell pulseState] == gradient_button_cell::kPulsingOn) || | 104 EXPECT_TRUE(([cell pulseState] == gradient_button_cell::kPulsingOn) || |
| 106 ([cell pulseState] == gradient_button_cell::kPulsedOn)); | 105 ([cell pulseState] == gradient_button_cell::kPulsedOn)); |
| 107 | 106 |
| 108 [cell setMouseInside:NO animate:YES]; | 107 [cell setMouseInside:NO animate:YES]; |
| 109 // Allow for immediate state changes to keep test unflaky | 108 // Allow for immediate state changes to keep test unflaky |
| 110 EXPECT_TRUE(([cell pulseState] == gradient_button_cell::kPulsingOff) || | 109 EXPECT_TRUE(([cell pulseState] == gradient_button_cell::kPulsingOff) || |
| 111 ([cell pulseState] == gradient_button_cell::kPulsedOff)); | 110 ([cell pulseState] == gradient_button_cell::kPulsedOff)); |
| 112 } | 111 } |
| 113 | 112 |
| 114 // Test drawing when first responder, mostly to ensure nothing leaks or | 113 // Test drawing when first responder, mostly to ensure nothing leaks or |
| 115 // crashes. | 114 // crashes. |
| 116 TEST_F(GradientButtonCellTest, FirstResponder) { | 115 TEST_F(GradientButtonCellTest, FirstResponder) { |
| 117 [test_window() makePretendKeyWindowAndSetFirstResponder:view_]; | 116 [test_window() makePretendKeyWindowAndSetFirstResponder:view_]; |
| 118 [view_ display]; | 117 [view_ display]; |
| 119 } | 118 } |
| 120 | 119 |
| 121 } // namespace | 120 } // namespace |
| OLD | NEW |