]> git.sesse.net Git - casparcg/blobdiff - dependencies64/cef/linux/tests/ceftests/image_util.cc
Upgrade CEF to 3.3029.1611.g44e39a8 / Chromium 58.0.3029.81.
[casparcg] / dependencies64 / cef / linux / tests / ceftests / image_util.cc
diff --git a/dependencies64/cef/linux/tests/ceftests/image_util.cc b/dependencies64/cef/linux/tests/ceftests/image_util.cc
new file mode 100644 (file)
index 0000000..29b7618
--- /dev/null
@@ -0,0 +1,38 @@
+// Copyright (c) 2016 The Chromium Embedded Framework 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 "tests/ceftests/image_util.h"
+
+#include "tests/gtest/include/gtest/gtest.h"
+#include "tests/shared/browser/resource_util.h"
+
+namespace image_util {
+
+void LoadImage(CefRefPtr<CefImage> image,
+               double scale_factor,
+               const std::string& name,
+               const CefSize& expected_size) {
+  std::string image_str;
+
+  std::string name_str;
+  if (scale_factor == 1.0f)
+    name_str = name + ".1x.png";
+  else if (scale_factor == 2.0f)
+    name_str = name + ".2x.png";
+
+  EXPECT_TRUE(client::LoadBinaryResource(name_str.c_str(), image_str));
+  EXPECT_TRUE(image->AddPNG(scale_factor, image_str.c_str(), image_str.size()));
+
+  EXPECT_FALSE(image->IsEmpty());
+  EXPECT_EQ(expected_size.width, static_cast<int>(image->GetWidth()));
+  EXPECT_EQ(expected_size.height, static_cast<int>(image->GetHeight()));
+}
+
+void LoadIconImage(CefRefPtr<CefImage> image,
+                   double scale_factor,
+                   const std::string& name) {
+  LoadImage(image, scale_factor, name, CefSize(16, 16));
+}
+
+}  // namespace image_util