Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(280)

Side by Side Diff: chrome/browser/ui/cocoa/constrained_window/constrained_window_animation_unittest.mm

Issue 19661004: Made MessagePump a non-thread safe class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adding a missing header. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/mac/scoped_nsobject.h" 5 #include "base/mac/scoped_nsobject.h"
6 #include "base/memory/scoped_ptr.h"
6 #include "base/message_loop/message_pump_mac.h" 7 #include "base/message_loop/message_pump_mac.h"
7 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" 8 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
8 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_animation .h" 9 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_animation .h"
9 10
10 // This class runs an animation for exactly two frames then end it. 11 // This class runs an animation for exactly two frames then end it.
11 @interface ConstrainedWindowAnimationTestDelegate : NSObject 12 @interface ConstrainedWindowAnimationTestDelegate : NSObject
12 <NSAnimationDelegate> { 13 <NSAnimationDelegate> {
13 @private 14 @private
14 CGFloat frameCount_; 15 CGFloat frameCount_;
15 scoped_refptr<base::MessagePumpNSRunLoop> message_pump_; 16 scoped_ptr<base::MessagePumpNSRunLoop> message_pump_;
16 } 17 }
17 18
18 - (void)runAnimation:(NSAnimation*)animation; 19 - (void)runAnimation:(NSAnimation*)animation;
19 20
20 @end 21 @end
21 22
22 @implementation ConstrainedWindowAnimationTestDelegate 23 @implementation ConstrainedWindowAnimationTestDelegate
23 24
24 - (id)init { 25 - (id)init {
25 if ((self = [super init])) 26 if ((self = [super init]))
26 message_pump_ = new base::MessagePumpNSRunLoop; 27 message_pump_.reset(new base::MessagePumpNSRunLoop);
27 return self; 28 return self;
28 } 29 }
29 30
30 - (float)animation:(NSAnimation*)animation 31 - (float)animation:(NSAnimation*)animation
31 valueForProgress:(NSAnimationProgress)progress { 32 valueForProgress:(NSAnimationProgress)progress {
32 ++frameCount_; 33 ++frameCount_;
33 if (frameCount_ >= 2) 34 if (frameCount_ >= 2)
34 [animation setDuration:0.0]; 35 [animation setDuration:0.0];
35 return frameCount_ == 1 ? 0.2 : 0.6; 36 return frameCount_ == 1 ? 0.2 : 0.6;
36 } 37 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 [[ConstrainedWindowAnimationHide alloc] initWithWindow:test_window()]); 74 [[ConstrainedWindowAnimationHide alloc] initWithWindow:test_window()]);
74 [delegate_ runAnimation:animation]; 75 [delegate_ runAnimation:animation];
75 } 76 }
76 77
77 // Test the pulse animation. 78 // Test the pulse animation.
78 TEST_F(ConstrainedWindowAnimationTest, Pulse) { 79 TEST_F(ConstrainedWindowAnimationTest, Pulse) {
79 base::scoped_nsobject<NSAnimation> animation( 80 base::scoped_nsobject<NSAnimation> animation(
80 [[ConstrainedWindowAnimationPulse alloc] initWithWindow:test_window()]); 81 [[ConstrainedWindowAnimationPulse alloc] initWithWindow:test_window()]);
81 [delegate_ runAnimation:animation]; 82 [delegate_ runAnimation:animation];
82 } 83 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698