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 "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/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/file_util.h" | 14 #include "base/file_util.h" |
15 #include "base/json/json_file_value_serializer.h" | 15 #include "base/json/json_file_value_serializer.h" |
16 #include "base/json/json_reader.h" | 16 #include "base/json/json_reader.h" |
17 #include "base/json/json_string_value_serializer.h" | 17 #include "base/json/json_string_value_serializer.h" |
18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
20 #include "base/message_loop.h" | 20 #include "base/message_loop.h" |
21 #include "base/path_service.h" | 21 #include "base/path_service.h" |
22 #include "base/scoped_temp_dir.h" | 22 #include "base/scoped_temp_dir.h" |
23 #include "base/stl_util.h" | 23 #include "base/stl_util.h" |
24 #include "base/string16.h" | 24 #include "base/string16.h" |
25 #include "base/string_number_conversions.h" | 25 #include "base/string_number_conversions.h" |
26 #include "base/string_util.h" | 26 #include "base/string_util.h" |
| 27 #include "base/threading/sequenced_worker_pool.h" |
27 #include "base/utf_string_conversions.h" | 28 #include "base/utf_string_conversions.h" |
28 #include "base/version.h" | 29 #include "base/version.h" |
29 #include "chrome/browser/browser_process.h" | 30 #include "chrome/browser/browser_process.h" |
30 #include "chrome/browser/extensions/app_sync_data.h" | 31 #include "chrome/browser/extensions/app_sync_data.h" |
31 #include "chrome/browser/extensions/component_loader.h" | 32 #include "chrome/browser/extensions/component_loader.h" |
32 #include "chrome/browser/extensions/crx_installer.h" | 33 #include "chrome/browser/extensions/crx_installer.h" |
33 #include "chrome/browser/extensions/default_apps.h" | 34 #include "chrome/browser/extensions/default_apps.h" |
34 #include "chrome/browser/extensions/extension_creator.h" | 35 #include "chrome/browser/extensions/extension_creator.h" |
35 #include "chrome/browser/extensions/extension_error_reporter.h" | 36 #include "chrome/browser/extensions/extension_error_reporter.h" |
36 #include "chrome/browser/extensions/extension_error_ui.h" | 37 #include "chrome/browser/extensions/extension_error_ui.h" |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 data_dir_ = test_data_dir.AppendASCII("extensions"); | 401 data_dir_ = test_data_dir.AppendASCII("extensions"); |
401 } | 402 } |
402 | 403 |
403 ExtensionServiceTestBase::~ExtensionServiceTestBase() { | 404 ExtensionServiceTestBase::~ExtensionServiceTestBase() { |
404 // Drop our reference to ExtensionService and TestingProfile, so that they | 405 // Drop our reference to ExtensionService and TestingProfile, so that they |
405 // can be destroyed while BrowserThreads and MessageLoop are still around | 406 // can be destroyed while BrowserThreads and MessageLoop are still around |
406 // (they are used in the destruction process). | 407 // (they are used in the destruction process). |
407 service_ = NULL; | 408 service_ = NULL; |
408 MessageLoop::current()->RunAllPending(); | 409 MessageLoop::current()->RunAllPending(); |
409 profile_.reset(NULL); | 410 profile_.reset(NULL); |
| 411 BrowserThread::GetBlockingPool()->FlushForTesting(); |
410 MessageLoop::current()->RunAllPending(); | 412 MessageLoop::current()->RunAllPending(); |
411 } | 413 } |
412 | 414 |
413 void ExtensionServiceTestBase::InitializeExtensionService( | 415 void ExtensionServiceTestBase::InitializeExtensionService( |
414 const FilePath& profile_path, | 416 const FilePath& profile_path, |
415 const FilePath& pref_file, | 417 const FilePath& pref_file, |
416 const FilePath& extensions_install_dir, | 418 const FilePath& extensions_install_dir, |
417 bool autoupdate_enabled) { | 419 bool autoupdate_enabled) { |
418 TestingProfile::Builder profile_builder; | 420 TestingProfile::Builder profile_builder; |
419 // Create a PrefService that only contains user defined preference values. | 421 // Create a PrefService that only contains user defined preference values. |
(...skipping 5165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5585 // This should NOT trigger an alert. | 5587 // This should NOT trigger an alert. |
5586 provider->UpdateOrAddExtension(hosted_app, "1.0.0.0", | 5588 provider->UpdateOrAddExtension(hosted_app, "1.0.0.0", |
5587 data_dir_.AppendASCII("hosted_app.crx")); | 5589 data_dir_.AppendASCII("hosted_app.crx")); |
5588 | 5590 |
5589 service_->CheckForExternalUpdates(); | 5591 service_->CheckForExternalUpdates(); |
5590 loop_.RunAllPending(); | 5592 loop_.RunAllPending(); |
5591 | 5593 |
5592 ASSERT_TRUE(service_->PopulateExtensionErrorUI(extension_error_ui.get())); | 5594 ASSERT_TRUE(service_->PopulateExtensionErrorUI(extension_error_ui.get())); |
5593 ASSERT_EQ(1u, extension_error_ui->get_external_extension_ids()->size()); | 5595 ASSERT_EQ(1u, extension_error_ui->get_external_extension_ids()->size()); |
5594 } | 5596 } |
OLD | NEW |