OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/common/safe_browsing/file_type_policies.h" | 5 #include "chrome/common/safe_browsing/file_type_policies.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 file_type.platform_settings(0).danger_level()); | 100 file_type.platform_settings(0).danger_level()); |
101 EXPECT_EQ(DownloadFileType::DISALLOW_AUTO_OPEN, | 101 EXPECT_EQ(DownloadFileType::DISALLOW_AUTO_OPEN, |
102 file_type.platform_settings(0).auto_open_hint()); | 102 file_type.platform_settings(0).auto_open_hint()); |
103 #else | 103 #else |
104 EXPECT_EQ(DownloadFileType::NOT_DANGEROUS, | 104 EXPECT_EQ(DownloadFileType::NOT_DANGEROUS, |
105 file_type.platform_settings(0).danger_level()); | 105 file_type.platform_settings(0).danger_level()); |
106 EXPECT_EQ(DownloadFileType::ALLOW_AUTO_OPEN, | 106 EXPECT_EQ(DownloadFileType::ALLOW_AUTO_OPEN, |
107 file_type.platform_settings(0).auto_open_hint()); | 107 file_type.platform_settings(0).auto_open_hint()); |
108 #endif | 108 #endif |
109 | 109 |
110 // Lookup .dex that varies on OS_ANDROID | 110 // Lookup .dex that varies on OS_ANDROID and OS_CHROMEOS |
111 base::FilePath dex_file(FILE_PATH_LITERAL("foo.dex")); | 111 base::FilePath dex_file(FILE_PATH_LITERAL("foo.dex")); |
112 file_type = policies_.PolicyForFile(dex_file); | 112 file_type = policies_.PolicyForFile(dex_file); |
113 EXPECT_EQ("dex", file_type.extension()); | 113 EXPECT_EQ("dex", file_type.extension()); |
114 EXPECT_EQ(143, file_type.uma_value()); | 114 EXPECT_EQ(143, file_type.uma_value()); |
115 EXPECT_FALSE(file_type.is_archive()); | 115 EXPECT_FALSE(file_type.is_archive()); |
116 EXPECT_EQ(DownloadFileType::FULL_PING, file_type.ping_setting()); | 116 EXPECT_EQ(DownloadFileType::FULL_PING, file_type.ping_setting()); |
117 #if defined(OS_ANDROID) | 117 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
118 EXPECT_EQ(DownloadFileType::ALLOW_ON_USER_GESTURE, | 118 EXPECT_EQ(DownloadFileType::ALLOW_ON_USER_GESTURE, |
119 file_type.platform_settings(0).danger_level()); | 119 file_type.platform_settings(0).danger_level()); |
120 EXPECT_EQ(DownloadFileType::DISALLOW_AUTO_OPEN, | 120 EXPECT_EQ(DownloadFileType::DISALLOW_AUTO_OPEN, |
121 file_type.platform_settings(0).auto_open_hint()); | 121 file_type.platform_settings(0).auto_open_hint()); |
122 #else | 122 #else |
123 EXPECT_EQ(DownloadFileType::NOT_DANGEROUS, | 123 EXPECT_EQ(DownloadFileType::NOT_DANGEROUS, |
124 file_type.platform_settings(0).danger_level()); | 124 file_type.platform_settings(0).danger_level()); |
125 EXPECT_EQ(DownloadFileType::ALLOW_AUTO_OPEN, | 125 EXPECT_EQ(DownloadFileType::ALLOW_AUTO_OPEN, |
126 file_type.platform_settings(0).auto_open_hint()); | 126 file_type.platform_settings(0).auto_open_hint()); |
127 #endif | 127 #endif |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 // Can't update to the same version | 210 // Can't update to the same version |
211 EXPECT_EQ(FileTypePolicies::UpdateResult::SKIPPED_VERSION_CHECK_EQUAL, | 211 EXPECT_EQ(FileTypePolicies::UpdateResult::SKIPPED_VERSION_CHECK_EQUAL, |
212 policies_.PopulateFromBinaryPb(cfg.SerializeAsString())); | 212 policies_.PopulateFromBinaryPb(cfg.SerializeAsString())); |
213 | 213 |
214 // Can't go backward | 214 // Can't go backward |
215 cfg.set_version_id(1); | 215 cfg.set_version_id(1); |
216 EXPECT_EQ(FileTypePolicies::UpdateResult::FAILED_VERSION_CHECK, | 216 EXPECT_EQ(FileTypePolicies::UpdateResult::FAILED_VERSION_CHECK, |
217 policies_.PopulateFromBinaryPb(cfg.SerializeAsString())); | 217 policies_.PopulateFromBinaryPb(cfg.SerializeAsString())); |
218 } | 218 } |
219 } // namespace safe_browsing | 219 } // namespace safe_browsing |
OLD | NEW |