Home | History | Annotate | Download | only in cocoa
      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
      3 // found in the LICENSE file.
      4 
      5 #import <Cocoa/Cocoa.h>
      6 
      7 #import "app/mac/nsimage_cache.h"
      8 #import "chrome/browser/ui/cocoa/animatable_image.h"
      9 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
     10 #include "testing/gtest/include/gtest/gtest.h"
     11 #include "testing/platform_test.h"
     12 
     13 namespace {
     14 
     15 class AnimatableImageTest : public CocoaTest {
     16  public:
     17   AnimatableImageTest() {
     18     NSRect frame = NSMakeRect(0, 0, 500, 500);
     19     NSImage* image = app::mac::GetCachedImageWithName(@"forward_Template.pdf");
     20     animation_ = [[AnimatableImage alloc] initWithImage:image
     21                                          animationFrame:frame];
     22   }
     23 
     24   AnimatableImage* animation_;
     25 };
     26 
     27 TEST_F(AnimatableImageTest, BasicAnimation) {
     28   [animation_ setStartFrame:CGRectMake(0, 0, 10, 10)];
     29   [animation_ setEndFrame:CGRectMake(500, 500, 100, 100)];
     30   [animation_ setStartOpacity:0.1];
     31   [animation_ setEndOpacity:1.0];
     32   [animation_ setDuration:0.5];
     33   [animation_ startAnimation];
     34 }
     35 
     36 TEST_F(AnimatableImageTest, CancelAnimation) {
     37   [animation_ setStartFrame:CGRectMake(0, 0, 10, 10)];
     38   [animation_ setEndFrame:CGRectMake(500, 500, 100, 100)];
     39   [animation_ setStartOpacity:0.1];
     40   [animation_ setEndOpacity:1.0];
     41   [animation_ setDuration:5.0];  // Long enough to be able to test cancelling.
     42   [animation_ startAnimation];
     43   [animation_ close];
     44 }
     45 
     46 }  // namespace
     47