Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Unified Diff: core/fxge/skia/fx_skia_device_unittest.cpp

Issue 1870463002: flesh out gradient shaders (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: fix linux-detected error Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/fxge/skia/fx_skia_device.cpp ('k') | pdfium.gyp » ('j') | pdfium.gyp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fxge/skia/fx_skia_device_unittest.cpp
diff --git a/core/fxge/skia/fx_skia_device_unittest.cpp b/core/fxge/skia/fx_skia_device_unittest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..57a4ec140b513b7dec5e55e0239fd5e839956ccc
--- /dev/null
+++ b/core/fxge/skia/fx_skia_device_unittest.cpp
@@ -0,0 +1,31 @@
+// Copyright 2016 PDFium 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 "core/fxge/skia/fx_skia_device.cpp"
+#include "testing/fx_string_testhelpers.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+uint32_t _GetBits32(const uint8_t* pData, int bitpos, int nbits) {
+ int result = 0;
+ for (int i = 0; i < nbits; i++)
+ if (pData[(bitpos + i) / 8] & (1 << (7 - (bitpos + i) % 8))) {
+ result |= 1 << (nbits - i - 1);
+ }
+ return result;
+}
+
+} // namespace
+
+TEST(fxge, GetBits32) {
+ unsigned char data[] = {0xDE, 0x3F, 0xB1, 0x7C, 0x12, 0x9A, 0x04, 0x56};
+ for (int nbits = 1; nbits <= 32; ++nbits) {
+ for (int bitpos = 0; bitpos < (int)sizeof(data) * 8 - nbits; ++bitpos) {
+ uint32_t ref = _GetBits32(data, bitpos, nbits);
+ uint32_t test = GetBits32(data, bitpos, nbits);
+ EXPECT_TRUE(ref == test);
+ }
+ }
+}
« no previous file with comments | « core/fxge/skia/fx_skia_device.cpp ('k') | pdfium.gyp » ('j') | pdfium.gyp » ('J')

Powered by Google App Engine
This is Rietveld 408576698