• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2016 The Chromium Embedded Framework Authors. All rights
2 // reserved. Use of this source code is governed by a BSD-style license that
3 // can be found in the LICENSE file.
4 
5 #include "tests/ceftests/image_util.h"
6 
7 #include "tests/gtest/include/gtest/gtest.h"
8 #include "tests/shared/browser/resource_util.h"
9 
10 namespace image_util {
11 
LoadImage(CefRefPtr<CefImage> image,double scale_factor,const std::string & name,const CefSize & expected_size)12 void LoadImage(CefRefPtr<CefImage> image,
13                double scale_factor,
14                const std::string& name,
15                const CefSize& expected_size) {
16   std::string image_str;
17 
18   std::string name_str;
19   if (scale_factor == 1.0f)
20     name_str = name + ".1x.png";
21   else if (scale_factor == 2.0f)
22     name_str = name + ".2x.png";
23 
24   EXPECT_TRUE(client::LoadBinaryResource(name_str.c_str(), image_str));
25   EXPECT_TRUE(image->AddPNG(scale_factor, image_str.c_str(), image_str.size()));
26 
27   EXPECT_FALSE(image->IsEmpty());
28   EXPECT_EQ(expected_size.width, static_cast<int>(image->GetWidth()));
29   EXPECT_EQ(expected_size.height, static_cast<int>(image->GetHeight()));
30 }
31 
LoadIconImage(CefRefPtr<CefImage> image,double scale_factor,const std::string & name)32 void LoadIconImage(CefRefPtr<CefImage> image,
33                    double scale_factor,
34                    const std::string& name) {
35   LoadImage(image, scale_factor, name, CefSize(16, 16));
36 }
37 
38 }  // namespace image_util
39