OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/base64.h" | 5 #include "base/base64.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "content/browser/devtools/devtools_protocol.h" | 8 #include "content/browser/devtools/devtools_protocol.h" |
9 #include "content/public/browser/devtools_agent_host.h" | 9 #include "content/public/browser/devtools_agent_host.h" |
10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 "document.body.style.background = '#123456'")); | 118 "document.body.style.background = '#123456'")); |
119 SendCommand("Page.captureScreenshot", new base::DictionaryValue()); | 119 SendCommand("Page.captureScreenshot", new base::DictionaryValue()); |
120 std::string base64; | 120 std::string base64; |
121 EXPECT_TRUE(result_->GetString("data", &base64)); | 121 EXPECT_TRUE(result_->GetString("data", &base64)); |
122 std::string png; | 122 std::string png; |
123 EXPECT_TRUE(base::Base64Decode(base64, &png)); | 123 EXPECT_TRUE(base::Base64Decode(base64, &png)); |
124 SkBitmap bitmap; | 124 SkBitmap bitmap; |
125 gfx::PNGCodec::Decode(reinterpret_cast<const unsigned char*>(png.data()), | 125 gfx::PNGCodec::Decode(reinterpret_cast<const unsigned char*>(png.data()), |
126 png.size(), &bitmap); | 126 png.size(), &bitmap); |
127 SkColor color(bitmap.getColor(0, 0)); | 127 SkColor color(bitmap.getColor(0, 0)); |
128 EXPECT_TRUE(std::abs(0x12-(int)SkColorGetR(color)) <= 1); | 128 EXPECT_LE(std::abs(0x12-(int)SkColorGetR(color)), 1); |
129 EXPECT_TRUE(std::abs(0x34-(int)SkColorGetG(color)) <= 1); | 129 EXPECT_LE(std::abs(0x34-(int)SkColorGetG(color)), 1); |
130 EXPECT_TRUE(std::abs(0x56-(int)SkColorGetB(color)) <= 1); | 130 EXPECT_LE(std::abs(0x56-(int)SkColorGetB(color)), 1); |
131 } | 131 } |
132 | 132 |
133 } // namespace content | 133 } // namespace content |
OLD | NEW |