OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/logging.h" | 5 #include "base/logging.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/metrics/field_trial.h" | 7 #include "base/metrics/field_trial.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "chrome/browser/safe_browsing/remote_database_manager.h" | 10 #include "chrome/browser/safe_browsing/remote_database_manager.h" |
11 #include "chrome/browser/safe_browsing/safe_browsing_api_handler.h" | 11 #include "chrome/browser/safe_browsing/safe_browsing_api_handler.h" |
12 #include "components/variations/variations_associated_data.h" | 12 #include "components/variations/variations_associated_data.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
| 15 namespace safe_browsing { |
| 16 |
15 namespace { | 17 namespace { |
16 | 18 |
17 class TestSafeBrowsingApiHandler : public SafeBrowsingApiHandler { | 19 class TestSafeBrowsingApiHandler : public SafeBrowsingApiHandler { |
18 public: | 20 public: |
19 void StartURLCheck(const URLCheckCallback& callback, | 21 void StartURLCheck(const URLCheckCallback& callback, |
20 const GURL& url, | 22 const GURL& url, |
21 const std::vector<SBThreatType>& threat_types) override {} | 23 const std::vector<SBThreatType>& threat_types) override {} |
22 }; | 24 }; |
23 | 25 |
| 26 } // namespace |
| 27 |
24 class RemoteDatabaseManagerTest : public testing::Test { | 28 class RemoteDatabaseManagerTest : public testing::Test { |
25 protected: | 29 protected: |
26 RemoteDatabaseManagerTest() : field_trials_(new base::FieldTrialList(NULL)) {} | 30 RemoteDatabaseManagerTest() : field_trials_(new base::FieldTrialList(NULL)) {} |
27 | 31 |
28 void SetUp() override { | 32 void SetUp() override { |
29 SafeBrowsingApiHandler::SetInstance(&api_handler_); | 33 SafeBrowsingApiHandler::SetInstance(&api_handler_); |
30 db_ = new RemoteSafeBrowsingDatabaseManager(); | 34 db_ = new RemoteSafeBrowsingDatabaseManager(); |
31 } | 35 } |
32 | 36 |
33 // Setup the two field trial params. These are read in db_'s ctor. | 37 // Setup the two field trial params. These are read in db_'s ctor. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 content::RESOURCE_TYPE_MAIN_FRAME)); // defaulted | 92 content::RESOURCE_TYPE_MAIN_FRAME)); // defaulted |
89 EXPECT_TRUE(db_->CanCheckResourceType(content::RESOURCE_TYPE_SUB_FRAME)); | 93 EXPECT_TRUE(db_->CanCheckResourceType(content::RESOURCE_TYPE_SUB_FRAME)); |
90 EXPECT_TRUE(db_->CanCheckResourceType(content::RESOURCE_TYPE_STYLESHEET)); | 94 EXPECT_TRUE(db_->CanCheckResourceType(content::RESOURCE_TYPE_STYLESHEET)); |
91 EXPECT_FALSE(db_->CanCheckResourceType(content::RESOURCE_TYPE_SCRIPT)); | 95 EXPECT_FALSE(db_->CanCheckResourceType(content::RESOURCE_TYPE_SCRIPT)); |
92 EXPECT_FALSE(db_->CanCheckResourceType(content::RESOURCE_TYPE_IMAGE)); | 96 EXPECT_FALSE(db_->CanCheckResourceType(content::RESOURCE_TYPE_IMAGE)); |
93 // ... | 97 // ... |
94 EXPECT_FALSE(db_->CanCheckResourceType(content::RESOURCE_TYPE_MEDIA)); | 98 EXPECT_FALSE(db_->CanCheckResourceType(content::RESOURCE_TYPE_MEDIA)); |
95 EXPECT_TRUE(db_->CanCheckResourceType(content::RESOURCE_TYPE_WORKER)); | 99 EXPECT_TRUE(db_->CanCheckResourceType(content::RESOURCE_TYPE_WORKER)); |
96 } | 100 } |
97 | 101 |
98 } // namespace | 102 } // namespace safe_browsing |
OLD | NEW |