| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <map> | 5 #include <map> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 154 |
| 155 // Invalid thumbnail. | 155 // Invalid thumbnail. |
| 156 SkBitmap thumbnail; | 156 SkBitmap thumbnail; |
| 157 GURL url("http://a.com/"); | 157 GURL url("http://a.com/"); |
| 158 double score = 0.4; // Some random client score. | 158 double score = 0.4; // Some random client score. |
| 159 EXPECT_FALSE(SendClientReportPhishingRequest(url, score, thumbnail)); | 159 EXPECT_FALSE(SendClientReportPhishingRequest(url, score, thumbnail)); |
| 160 | 160 |
| 161 // Valid thumbnail but the server returns an error. | 161 // Valid thumbnail but the server returns an error. |
| 162 thumbnail.setConfig(SkBitmap::kARGB_8888_Config, 100, 100); | 162 thumbnail.setConfig(SkBitmap::kARGB_8888_Config, 100, 100); |
| 163 ASSERT_TRUE(thumbnail.allocPixels()); | 163 ASSERT_TRUE(thumbnail.allocPixels()); |
| 164 thumbnail.eraseRGB(255, 0, 0); |
| 164 SetClientReportPhishingResponse("", false /* fail */); | 165 SetClientReportPhishingResponse("", false /* fail */); |
| 165 EXPECT_FALSE(SendClientReportPhishingRequest(url, score, thumbnail)); | 166 EXPECT_FALSE(SendClientReportPhishingRequest(url, score, thumbnail)); |
| 166 | 167 |
| 167 // Invalid response body from the server. | 168 // Invalid response body from the server. |
| 168 SetClientReportPhishingResponse("invalid proto response", true /* success */); | 169 SetClientReportPhishingResponse("invalid proto response", true /* success */); |
| 169 EXPECT_FALSE(SendClientReportPhishingRequest(url, score, thumbnail)); | 170 EXPECT_FALSE(SendClientReportPhishingRequest(url, score, thumbnail)); |
| 170 | 171 |
| 171 // Normal behavior. | 172 // Normal behavior. |
| 172 ClientPhishingResponse response; | 173 ClientPhishingResponse response; |
| 173 response.set_phishy(true); | 174 response.set_phishy(true); |
| 174 SetClientReportPhishingResponse(response.SerializeAsString(), | 175 SetClientReportPhishingResponse(response.SerializeAsString(), |
| 175 true /* success */); | 176 true /* success */); |
| 176 EXPECT_TRUE(SendClientReportPhishingRequest(url, score, thumbnail)); | 177 EXPECT_TRUE(SendClientReportPhishingRequest(url, score, thumbnail)); |
| 177 response.set_phishy(false); | 178 response.set_phishy(false); |
| 178 SetClientReportPhishingResponse(response.SerializeAsString(), | 179 SetClientReportPhishingResponse(response.SerializeAsString(), |
| 179 true /* success */); | 180 true /* success */); |
| 180 EXPECT_FALSE(SendClientReportPhishingRequest(url, score, thumbnail)); | 181 EXPECT_FALSE(SendClientReportPhishingRequest(url, score, thumbnail)); |
| 181 } | 182 } |
| 182 | 183 |
| 183 } // namespace safe_browsing | 184 } // namespace safe_browsing |
| OLD | NEW |