summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/cocoa/animatable_image_unittest.mm
blob: 112e8dd4f060b66b00be5d63890dc6e7967b7126 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Cocoa/Cocoa.h>

#import "app/mac/nsimage_cache.h"
#import "chrome/browser/ui/cocoa/animatable_image.h"
#import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"

namespace {

class AnimatableImageTest : public CocoaTest {
 public:
  AnimatableImageTest() {
    NSRect frame = NSMakeRect(0, 0, 500, 500);
    NSImage* image = app::mac::GetCachedImageWithName(@"forward_Template.pdf");
    animation_ = [[AnimatableImage alloc] initWithImage:image
                                         animationFrame:frame];
  }

  AnimatableImage* animation_;
};

TEST_F(AnimatableImageTest, BasicAnimation) {
  [animation_ setStartFrame:CGRectMake(0, 0, 10, 10)];
  [animation_ setEndFrame:CGRectMake(500, 500, 100, 100)];
  [animation_ setStartOpacity:0.1];
  [animation_ setEndOpacity:1.0];
  [animation_ setDuration:0.5];
  [animation_ startAnimation];
}

TEST_F(AnimatableImageTest, CancelAnimation) {
  [animation_ setStartFrame:CGRectMake(0, 0, 10, 10)];
  [animation_ setEndFrame:CGRectMake(500, 500, 100, 100)];
  [animation_ setStartOpacity:0.1];
  [animation_ setEndOpacity:1.0];
  [animation_ setDuration:5.0];  // Long enough to be able to test cancelling.
  [animation_ startAnimation];
  [animation_ close];
}

}  // namespace