OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/apps/drive/drive_app_provider.h" | 5 #include "chrome/browser/apps/drive/drive_app_provider.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "base/timer/timer.h" | 12 #include "base/timer/timer.h" |
13 #include "chrome/browser/apps/drive/drive_app_mapping.h" | 13 #include "chrome/browser/apps/drive/drive_app_mapping.h" |
14 #include "chrome/browser/apps/drive/drive_service_bridge.h" | 14 #include "chrome/browser/apps/drive/drive_service_bridge.h" |
15 #include "chrome/browser/drive/drive_app_registry.h" | 15 #include "chrome/browser/drive/drive_app_registry.h" |
16 #include "chrome/browser/drive/fake_drive_service.h" | 16 #include "chrome/browser/drive/fake_drive_service.h" |
17 #include "chrome/browser/extensions/crx_installer.h" | 17 #include "chrome/browser/extensions/crx_installer.h" |
18 #include "chrome/browser/extensions/extension_browsertest.h" | 18 #include "chrome/browser/extensions/extension_browsertest.h" |
19 #include "chrome/browser/extensions/install_tracker.h" | 19 #include "chrome/browser/extensions/install_tracker.h" |
| 20 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" |
| 21 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" |
20 #include "chrome/common/chrome_paths.h" | 22 #include "chrome/common/chrome_paths.h" |
21 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 23 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
22 #include "chrome/common/web_application_info.h" | 24 #include "chrome/common/web_application_info.h" |
23 #include "content/public/test/test_utils.h" | 25 #include "content/public/test/test_utils.h" |
24 #include "extensions/browser/extension_registry.h" | 26 #include "extensions/browser/extension_registry.h" |
25 #include "extensions/browser/extension_system.h" | 27 #include "extensions/browser/extension_system.h" |
26 | 28 |
27 using extensions::AppLaunchInfo; | 29 using extensions::AppLaunchInfo; |
28 using extensions::Extension; | 30 using extensions::Extension; |
29 using extensions::ExtensionRegistry; | 31 using extensions::ExtensionRegistry; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 70 |
69 fake_drive_service_.reset(new drive::FakeDriveService); | 71 fake_drive_service_.reset(new drive::FakeDriveService); |
70 fake_drive_service_->LoadAppListForDriveApi("drive/applist_empty.json"); | 72 fake_drive_service_->LoadAppListForDriveApi("drive/applist_empty.json"); |
71 apps_registry_.reset( | 73 apps_registry_.reset( |
72 new drive::DriveAppRegistry(fake_drive_service_.get())); | 74 new drive::DriveAppRegistry(fake_drive_service_.get())); |
73 | 75 |
74 provider_.reset(new DriveAppProvider(profile())); | 76 provider_.reset(new DriveAppProvider(profile())); |
75 provider_->SetDriveServiceBridgeForTest( | 77 provider_->SetDriveServiceBridgeForTest( |
76 make_scoped_ptr(new TestDriveServiceBridge(apps_registry_.get())) | 78 make_scoped_ptr(new TestDriveServiceBridge(apps_registry_.get())) |
77 .PassAs<DriveServiceBridge>()); | 79 .PassAs<DriveServiceBridge>()); |
| 80 |
| 81 // The DriveAppProvider in AppListSyncalbeService interferes with the |
| 82 // test. So resets it. |
| 83 app_list::AppListSyncableServiceFactory::GetForProfile(profile()) |
| 84 ->ResetDriveAppProviderForTest(); |
78 } | 85 } |
79 | 86 |
80 virtual void TearDownOnMainThread() OVERRIDE { | 87 virtual void TearDownOnMainThread() OVERRIDE { |
81 provider_.reset(); | 88 provider_.reset(); |
82 apps_registry_.reset(); | 89 apps_registry_.reset(); |
83 fake_drive_service_.reset(); | 90 fake_drive_service_.reset(); |
84 | 91 |
85 ExtensionBrowserTest::TearDownOnMainThread(); | 92 ExtensionBrowserTest::TearDownOnMainThread(); |
86 } | 93 } |
87 | 94 |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 InstallUserUrlApp(kLaunchUrl); | 451 InstallUserUrlApp(kLaunchUrl); |
445 EXPECT_FALSE(mapping()->IsChromeAppGenerated(url_app_id)); | 452 EXPECT_FALSE(mapping()->IsChromeAppGenerated(url_app_id)); |
446 | 453 |
447 fake_drive_service()->RemoveAppByProductId(kChromeAppId); | 454 fake_drive_service()->RemoveAppByProductId(kChromeAppId); |
448 RefreshDriveAppRegistry(); | 455 RefreshDriveAppRegistry(); |
449 | 456 |
450 // Url app is still present after the Drive app is disconnected. | 457 // Url app is still present after the Drive app is disconnected. |
451 EXPECT_TRUE(ExtensionRegistry::Get(profile())->GetExtensionById( | 458 EXPECT_TRUE(ExtensionRegistry::Get(profile())->GetExtensionById( |
452 url_app_id, ExtensionRegistry::EVERYTHING)); | 459 url_app_id, ExtensionRegistry::EVERYTHING)); |
453 } | 460 } |
OLD | NEW |