// Copyright (c) 2012 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.

#include "ui/gfx/transform_util.h"

#include "ui/gfx/point.h"
#include "testing/gtest/include/gtest/gtest.h"

TEST(TransformUtilTest, GetScaleTransform) {
  const gfx::Point kAnchor(20, 40);
  const float kScale = 0.5f;

  gfx::Transform scale = gfx::GetScaleTransform(kAnchor, kScale);

  const int kOffset = 10;
  for (int sign_x = -1; sign_x <= 1; ++sign_x) {
    for (int sign_y = -1; sign_y <= 1; ++sign_y) {
      gfx::Point test(kAnchor.x() + sign_x * kOffset,
                      kAnchor.y() + sign_y * kOffset);
      scale.TransformPoint(test);

      EXPECT_EQ(gfx::Point(kAnchor.x() + sign_x * kOffset * kScale,
                           kAnchor.y() + sign_y * kOffset * kScale),
                test);
    }
  }
}

// Copyright (c) 2012 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.

#include "ui/gfx/transform_util.h"

#include "ui/gfx/point.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace gfx {
namespace {

TEST(TransformUtilTest, GetScaleTransform) {
  const Point kAnchor(20, 40);
  const float kScale = 0.5f;

  Transform scale = GetScaleTransform(kAnchor, kScale);

  const int kOffset = 10;
  for (int sign_x = -1; sign_x <= 1; ++sign_x) {
    for (int sign_y = -1; sign_y <= 1; ++sign_y) {
      Point test(kAnchor.x() + sign_x * kOffset,
                 kAnchor.y() + sign_y * kOffset);
      scale.TransformPoint(test);

      EXPECT_EQ(Point(kAnchor.x() + sign_x * kOffset * kScale,
                      kAnchor.y() + sign_y * kOffset * kScale),
                test);
    }
  }
}

}  // namespace
}  // namespace gfx

Move transform_util unittest into gfx namespace.
ui/gfx: Move transform_util unittest into gfx namespace.

TEST=ui_unittests
TBR=sky@chromium.org


Review URL: https://chromiumcodereview.appspot.com/11369173

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@167060 0039d316-1c4b-4281-b951-d872f2087c98
