- add sources.
[platform/framework/web/crosswalk.git] / src / ui / gfx / test / color_util.cc
1 // Copyright 2013 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 #include "ui/gfx/test/color_util.h"
6
7 #include <iomanip>
8 #include <sstream>
9 #include <string>
10
11 namespace gfx {
12
13 namespace {
14
15 std::string ColorAsString(SkColor color) {
16   std::ostringstream stream;
17   stream << std::hex << std::uppercase << "#" << std::setfill('0')
18          << std::setw(2) << SkColorGetA(color)
19          << std::setw(2) << SkColorGetR(color)
20          << std::setw(2) << SkColorGetG(color)
21          << std::setw(2) << SkColorGetB(color);
22   return stream.str();
23 }
24
25 }  // namespace
26
27 ::testing::AssertionResult AssertSkColorsEqual(const char* lhs_expr,
28                                                const char* rhs_expr,
29                                                SkColor lhs,
30                                                SkColor rhs) {
31   if (lhs == rhs) {
32     return ::testing::AssertionSuccess();
33   }
34   return ::testing::AssertionFailure() << "Value of: " << rhs_expr
35                                        << "\n  Actual: " << ColorAsString(rhs)
36                                        << "\nExpected: " << lhs_expr
37                                        << "\nWhich is: " << ColorAsString(lhs);
38 }
39
40 }  // namespace gfx