OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/pickle.h" | 8 #include "base/pickle.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 141 |
142 class MockSafeBrowsingUIManager : public SafeBrowsingUIManager { | 142 class MockSafeBrowsingUIManager : public SafeBrowsingUIManager { |
143 public: | 143 public: |
144 base::RunLoop* run_loop_; | 144 base::RunLoop* run_loop_; |
145 // The safe browsing UI manager does not need a service for this test. | 145 // The safe browsing UI manager does not need a service for this test. |
146 MockSafeBrowsingUIManager() | 146 MockSafeBrowsingUIManager() |
147 : SafeBrowsingUIManager(NULL), run_loop_(NULL) {} | 147 : SafeBrowsingUIManager(NULL), run_loop_(NULL) {} |
148 | 148 |
149 // When the MalwareDetails is done, this is called. | 149 // When the MalwareDetails is done, this is called. |
150 virtual void SendSerializedMalwareDetails( | 150 virtual void SendSerializedMalwareDetails( |
151 const std::string& serialized) OVERRIDE { | 151 const std::string& serialized) override { |
152 DVLOG(1) << "SendSerializedMalwareDetails"; | 152 DVLOG(1) << "SendSerializedMalwareDetails"; |
153 run_loop_->Quit(); | 153 run_loop_->Quit(); |
154 run_loop_ = NULL; | 154 run_loop_ = NULL; |
155 serialized_ = serialized; | 155 serialized_ = serialized; |
156 } | 156 } |
157 | 157 |
158 // Used to synchronize SendSerializedMalwareDetails() with | 158 // Used to synchronize SendSerializedMalwareDetails() with |
159 // WaitForSerializedReport(). RunLoop::RunUntilIdle() is not sufficient | 159 // WaitForSerializedReport(). RunLoop::RunUntilIdle() is not sufficient |
160 // because the MessageLoop task queue completely drains at some point | 160 // because the MessageLoop task queue completely drains at some point |
161 // between the send and the wait. | 161 // between the send and the wait. |
(...skipping 16 matching lines...) Expand all Loading... |
178 } // namespace. | 178 } // namespace. |
179 | 179 |
180 class MalwareDetailsTest : public ChromeRenderViewHostTestHarness { | 180 class MalwareDetailsTest : public ChromeRenderViewHostTestHarness { |
181 public: | 181 public: |
182 typedef SafeBrowsingUIManager::UnsafeResource UnsafeResource; | 182 typedef SafeBrowsingUIManager::UnsafeResource UnsafeResource; |
183 | 183 |
184 MalwareDetailsTest() | 184 MalwareDetailsTest() |
185 : ui_manager_(new MockSafeBrowsingUIManager()) { | 185 : ui_manager_(new MockSafeBrowsingUIManager()) { |
186 } | 186 } |
187 | 187 |
188 virtual void SetUp() OVERRIDE { | 188 virtual void SetUp() override { |
189 ChromeRenderViewHostTestHarness::SetUp(); | 189 ChromeRenderViewHostTestHarness::SetUp(); |
190 ASSERT_TRUE(profile()->CreateHistoryService( | 190 ASSERT_TRUE(profile()->CreateHistoryService( |
191 true /* delete_file */, false /* no_db */)); | 191 true /* delete_file */, false /* no_db */)); |
192 } | 192 } |
193 | 193 |
194 virtual void TearDown() OVERRIDE { | 194 virtual void TearDown() override { |
195 profile()->DestroyHistoryService(); | 195 profile()->DestroyHistoryService(); |
196 ChromeRenderViewHostTestHarness::TearDown(); | 196 ChromeRenderViewHostTestHarness::TearDown(); |
197 } | 197 } |
198 | 198 |
199 static bool ResourceLessThan( | 199 static bool ResourceLessThan( |
200 const ClientMalwareReportRequest::Resource* lhs, | 200 const ClientMalwareReportRequest::Resource* lhs, |
201 const ClientMalwareReportRequest::Resource* rhs) { | 201 const ClientMalwareReportRequest::Resource* rhs) { |
202 return lhs->id() < rhs->id(); | 202 return lhs->id() < rhs->id(); |
203 } | 203 } |
204 | 204 |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 pb_resource = expected.add_resources(); | 684 pb_resource = expected.add_resources(); |
685 pb_resource->set_id(2); | 685 pb_resource->set_id(2); |
686 pb_resource->set_parent_id(3); | 686 pb_resource->set_parent_id(3); |
687 pb_resource->set_url(kSecondRedirectURL); | 687 pb_resource->set_url(kSecondRedirectURL); |
688 pb_resource = expected.add_resources(); | 688 pb_resource = expected.add_resources(); |
689 pb_resource->set_id(3); | 689 pb_resource->set_id(3); |
690 pb_resource->set_url(kFirstRedirectURL); | 690 pb_resource->set_url(kFirstRedirectURL); |
691 | 691 |
692 VerifyResults(actual, expected); | 692 VerifyResults(actual, expected); |
693 } | 693 } |
OLD | NEW |