OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/environment.h" | 5 #include "base/environment.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/i18n/case_conversion.h" | 8 #include "base/i18n/case_conversion.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/scoped_native_library.h" | 10 #include "base/scoped_native_library.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 EXPECT_TRUE(blacklist::ResetBeacon()); | 75 EXPECT_TRUE(blacklist::ResetBeacon()); |
76 | 76 |
77 // First call should succeed as the beacon is enabled. | 77 // First call should succeed as the beacon is enabled. |
78 EXPECT_TRUE(blacklist::LeaveSetupBeacon()); | 78 EXPECT_TRUE(blacklist::LeaveSetupBeacon()); |
79 | 79 |
80 // Second call should fail indicating the beacon wasn't set as enabled. | 80 // Second call should fail indicating the beacon wasn't set as enabled. |
81 EXPECT_FALSE(blacklist::LeaveSetupBeacon()); | 81 EXPECT_FALSE(blacklist::LeaveSetupBeacon()); |
82 | 82 |
83 // Resetting the beacon should work when setup beacon is present. | 83 // Resetting the beacon should work when setup beacon is present. |
84 EXPECT_TRUE(blacklist::ResetBeacon()); | 84 EXPECT_TRUE(blacklist::ResetBeacon()); |
85 | |
86 // Change the version and ensure that the setup fails due to the version | |
87 // mismatch. | |
88 base::string16 different_version(L"other_version"); | |
89 ASSERT_NE(different_version, TEXT(CHROME_VERSION_STRING)); | |
90 | |
91 result = blacklist_registry_key.WriteValue(blacklist::kBeaconVersion, | |
92 different_version.c_str()); | |
93 EXPECT_EQ(ERROR_SUCCESS, result); | |
94 | |
95 EXPECT_FALSE(blacklist::LeaveSetupBeacon()); | |
96 } | 85 } |
97 | 86 |
98 TEST_F(BlacklistTest, AddAndRemoveModules) { | 87 TEST_F(BlacklistTest, AddAndRemoveModules) { |
99 EXPECT_TRUE(blacklist::AddDllToBlacklist(L"foo.dll")); | 88 EXPECT_TRUE(blacklist::AddDllToBlacklist(L"foo.dll")); |
100 // Adding the same item twice should be idempotent. | 89 // Adding the same item twice should be idempotent. |
101 EXPECT_TRUE(blacklist::AddDllToBlacklist(L"foo.dll")); | 90 EXPECT_TRUE(blacklist::AddDllToBlacklist(L"foo.dll")); |
102 EXPECT_TRUE(blacklist::RemoveDllFromBlacklist(L"foo.dll")); | 91 EXPECT_TRUE(blacklist::RemoveDllFromBlacklist(L"foo.dll")); |
103 EXPECT_FALSE(blacklist::RemoveDllFromBlacklist(L"foo.dll")); | 92 EXPECT_FALSE(blacklist::RemoveDllFromBlacklist(L"foo.dll")); |
104 | 93 |
105 // Increase the blacklist size by 1 to include the NULL pointer | 94 // Increase the blacklist size by 1 to include the NULL pointer |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 dll_blacklisted_different_case.Reset(NULL); | 200 dll_blacklisted_different_case.Reset(NULL); |
212 | 201 |
213 EXPECT_TRUE(TestDll_RemoveDllFromBlacklist(uppercase_name.c_str())); | 202 EXPECT_TRUE(TestDll_RemoveDllFromBlacklist(uppercase_name.c_str())); |
214 | 203 |
215 // The blocked dll was removed, so we shouldn't get anything returned | 204 // The blocked dll was removed, so we shouldn't get anything returned |
216 // here. | 205 // here. |
217 TestDll_SuccessfullyBlocked(NULL, &num_blocked_dlls); | 206 TestDll_SuccessfullyBlocked(NULL, &num_blocked_dlls); |
218 EXPECT_EQ(0, num_blocked_dlls); | 207 EXPECT_EQ(0, num_blocked_dlls); |
219 } | 208 } |
220 } | 209 } |
OLD | NEW |