| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 EXPECT_NE(model_file, base::kInvalidPlatformFileValue); | 138 EXPECT_NE(model_file, base::kInvalidPlatformFileValue); |
| 139 EXPECT_EQ(ReadModelFile(model_file), "BOGUS MODEL"); | 139 EXPECT_EQ(ReadModelFile(model_file), "BOGUS MODEL"); |
| 140 | 140 |
| 141 // If the model does not exist and the fetch fails we should get an error. | 141 // If the model does not exist and the fetch fails we should get an error. |
| 142 model_path = tmp_dir.path().AppendASCII("another_model"); | 142 model_path = tmp_dir.path().AppendASCII("another_model"); |
| 143 SetModelFetchResponse("", false /* success */); | 143 SetModelFetchResponse("", false /* success */); |
| 144 csd_service_.reset(ClientSideDetectionService::Create(model_path, NULL)); | 144 csd_service_.reset(ClientSideDetectionService::Create(model_path, NULL)); |
| 145 EXPECT_EQ(GetModelFile(), base::kInvalidPlatformFileValue); | 145 EXPECT_EQ(GetModelFile(), base::kInvalidPlatformFileValue); |
| 146 } | 146 } |
| 147 | 147 |
| 148 TEST_F(ClientSideDetectionServiceTest, SendClientReportPhishingRequest) { | 148 #if defined(OS_MACOSX) |
| 149 // Sometimes crashes on Mac 10.5 bot: http://crbug.com/63358 |
| 150 #define MAYBE_SendClientReportPhishingRequest \ |
| 151 DISABLED_SendClientReportPhishingRequest |
| 152 #else |
| 153 #define MAYBE_SendClientReportPhishingRequest SendClientReportPhishingRequest |
| 154 #endif |
| 155 TEST_F(ClientSideDetectionServiceTest, MAYBE_SendClientReportPhishingRequest) { |
| 149 SetModelFetchResponse("bogus model", true /* success */); | 156 SetModelFetchResponse("bogus model", true /* success */); |
| 150 ScopedTempDir tmp_dir; | 157 ScopedTempDir tmp_dir; |
| 151 ASSERT_TRUE(tmp_dir.CreateUniqueTempDir()); | 158 ASSERT_TRUE(tmp_dir.CreateUniqueTempDir()); |
| 152 csd_service_.reset(ClientSideDetectionService::Create( | 159 csd_service_.reset(ClientSideDetectionService::Create( |
| 153 tmp_dir.path().AppendASCII("model"), NULL)); | 160 tmp_dir.path().AppendASCII("model"), NULL)); |
| 154 | 161 |
| 155 // Invalid thumbnail. | 162 // Invalid thumbnail. |
| 156 SkBitmap thumbnail; | 163 SkBitmap thumbnail; |
| 157 GURL url("http://a.com/"); | 164 GURL url("http://a.com/"); |
| 158 double score = 0.4; // Some random client score. | 165 double score = 0.4; // Some random client score. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 175 SetClientReportPhishingResponse(response.SerializeAsString(), | 182 SetClientReportPhishingResponse(response.SerializeAsString(), |
| 176 true /* success */); | 183 true /* success */); |
| 177 EXPECT_TRUE(SendClientReportPhishingRequest(url, score, thumbnail)); | 184 EXPECT_TRUE(SendClientReportPhishingRequest(url, score, thumbnail)); |
| 178 response.set_phishy(false); | 185 response.set_phishy(false); |
| 179 SetClientReportPhishingResponse(response.SerializeAsString(), | 186 SetClientReportPhishingResponse(response.SerializeAsString(), |
| 180 true /* success */); | 187 true /* success */); |
| 181 EXPECT_FALSE(SendClientReportPhishingRequest(url, score, thumbnail)); | 188 EXPECT_FALSE(SendClientReportPhishingRequest(url, score, thumbnail)); |
| 182 } | 189 } |
| 183 | 190 |
| 184 } // namespace safe_browsing | 191 } // namespace safe_browsing |
| OLD | NEW |