OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/browser/extensions/extension_service_unittest.h" | 5 #include "chrome/browser/extensions/extension_service_unittest.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/at_exit.h" | 11 #include "base/at_exit.h" |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
| 16 #include "base/files/file_enumerator.h" |
16 #include "base/files/scoped_temp_dir.h" | 17 #include "base/files/scoped_temp_dir.h" |
17 #include "base/json/json_file_value_serializer.h" | 18 #include "base/json/json_file_value_serializer.h" |
18 #include "base/json/json_reader.h" | 19 #include "base/json/json_reader.h" |
19 #include "base/json/json_string_value_serializer.h" | 20 #include "base/json/json_string_value_serializer.h" |
20 #include "base/memory/scoped_ptr.h" | 21 #include "base/memory/scoped_ptr.h" |
21 #include "base/memory/weak_ptr.h" | 22 #include "base/memory/weak_ptr.h" |
22 #include "base/message_loop.h" | 23 #include "base/message_loop.h" |
23 #include "base/path_service.h" | 24 #include "base/path_service.h" |
24 #include "base/stl_util.h" | 25 #include "base/stl_util.h" |
25 #include "base/string16.h" | 26 #include "base/string16.h" |
(...skipping 1321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1347 DictionaryPrefUpdate update(profile_->GetPrefs(), "extensions.settings"); | 1348 DictionaryPrefUpdate update(profile_->GetPrefs(), "extensions.settings"); |
1348 DictionaryValue* dict = update.Get(); | 1349 DictionaryValue* dict = update.Get(); |
1349 ASSERT_TRUE(dict != NULL); | 1350 ASSERT_TRUE(dict != NULL); |
1350 dict->Remove("behllobkkfkfnphdnhnkndlbkcpglgmj", NULL); | 1351 dict->Remove("behllobkkfkfnphdnhnkndlbkcpglgmj", NULL); |
1351 } | 1352 } |
1352 | 1353 |
1353 service_->Init(); | 1354 service_->Init(); |
1354 // Wait for GarbageCollectExtensions task to complete. | 1355 // Wait for GarbageCollectExtensions task to complete. |
1355 loop_.RunUntilIdle(); | 1356 loop_.RunUntilIdle(); |
1356 | 1357 |
1357 file_util::FileEnumerator dirs(extensions_install_dir_, false, | 1358 base::FileEnumerator dirs(extensions_install_dir_, false, |
1358 file_util::FileEnumerator::DIRECTORIES); | 1359 base::FileEnumerator::DIRECTORIES); |
1359 size_t count = 0; | 1360 size_t count = 0; |
1360 while (!dirs.Next().empty()) | 1361 while (!dirs.Next().empty()) |
1361 count++; | 1362 count++; |
1362 | 1363 |
1363 // We should have only gotten two extensions now. | 1364 // We should have only gotten two extensions now. |
1364 EXPECT_EQ(2u, count); | 1365 EXPECT_EQ(2u, count); |
1365 | 1366 |
1366 // And extension1 dir should now be toast. | 1367 // And extension1 dir should now be toast. |
1367 base::FilePath extension_dir = extensions_install_dir_ | 1368 base::FilePath extension_dir = extensions_install_dir_ |
1368 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj"); | 1369 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj"); |
(...skipping 4650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6019 new MockExtensionProvider(service_, Manifest::EXTERNAL_PREF); | 6020 new MockExtensionProvider(service_, Manifest::EXTERNAL_PREF); |
6020 AddMockExternalProvider(provider); | 6021 AddMockExternalProvider(provider); |
6021 provider->UpdateOrAddExtension(updates_from_webstore, "1", crx_path); | 6022 provider->UpdateOrAddExtension(updates_from_webstore, "1", crx_path); |
6022 | 6023 |
6023 service_->CheckForExternalUpdates(); | 6024 service_->CheckForExternalUpdates(); |
6024 loop_.RunUntilIdle(); | 6025 loop_.RunUntilIdle(); |
6025 EXPECT_TRUE(extensions::HasExternalInstallError(service_)); | 6026 EXPECT_TRUE(extensions::HasExternalInstallError(service_)); |
6026 EXPECT_FALSE(extensions::HasExternalInstallBubble(service_)); | 6027 EXPECT_FALSE(extensions::HasExternalInstallBubble(service_)); |
6027 EXPECT_FALSE(service_->IsExtensionEnabled(updates_from_webstore)); | 6028 EXPECT_FALSE(service_->IsExtensionEnabled(updates_from_webstore)); |
6028 } | 6029 } |
OLD | NEW |