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" |
(...skipping 28 matching lines...) Expand all Loading... |
39 // App id of hosted_app.crx. | 39 // App id of hosted_app.crx. |
40 const char kChromeAppId[] = "kbmnembihfiondgfjekmnmcbddelicoi"; | 40 const char kChromeAppId[] = "kbmnembihfiondgfjekmnmcbddelicoi"; |
41 | 41 |
42 // Stub drive service bridge. | 42 // Stub drive service bridge. |
43 class TestDriveServiceBridge : public DriveServiceBridge { | 43 class TestDriveServiceBridge : public DriveServiceBridge { |
44 public: | 44 public: |
45 explicit TestDriveServiceBridge(drive::DriveAppRegistry* registry) | 45 explicit TestDriveServiceBridge(drive::DriveAppRegistry* registry) |
46 : registry_(registry) {} | 46 : registry_(registry) {} |
47 virtual ~TestDriveServiceBridge() {} | 47 virtual ~TestDriveServiceBridge() {} |
48 | 48 |
49 virtual drive::DriveAppRegistry* GetAppRegistry() OVERRIDE { | 49 virtual drive::DriveAppRegistry* GetAppRegistry() override { |
50 return registry_; | 50 return registry_; |
51 } | 51 } |
52 | 52 |
53 private: | 53 private: |
54 drive::DriveAppRegistry* registry_; | 54 drive::DriveAppRegistry* registry_; |
55 | 55 |
56 DISALLOW_COPY_AND_ASSIGN(TestDriveServiceBridge); | 56 DISALLOW_COPY_AND_ASSIGN(TestDriveServiceBridge); |
57 }; | 57 }; |
58 | 58 |
59 } // namespace | 59 } // namespace |
60 | 60 |
61 class DriveAppProviderTest : public ExtensionBrowserTest, | 61 class DriveAppProviderTest : public ExtensionBrowserTest, |
62 public extensions::InstallObserver { | 62 public extensions::InstallObserver { |
63 public: | 63 public: |
64 DriveAppProviderTest() {} | 64 DriveAppProviderTest() {} |
65 virtual ~DriveAppProviderTest() {} | 65 virtual ~DriveAppProviderTest() {} |
66 | 66 |
67 // ExtensionBrowserTest: | 67 // ExtensionBrowserTest: |
68 virtual void SetUpOnMainThread() OVERRIDE { | 68 virtual void SetUpOnMainThread() override { |
69 ExtensionBrowserTest::SetUpOnMainThread(); | 69 ExtensionBrowserTest::SetUpOnMainThread(); |
70 | 70 |
71 fake_drive_service_.reset(new drive::FakeDriveService); | 71 fake_drive_service_.reset(new drive::FakeDriveService); |
72 fake_drive_service_->LoadAppListForDriveApi("drive/applist_empty.json"); | 72 fake_drive_service_->LoadAppListForDriveApi("drive/applist_empty.json"); |
73 apps_registry_.reset( | 73 apps_registry_.reset( |
74 new drive::DriveAppRegistry(fake_drive_service_.get())); | 74 new drive::DriveAppRegistry(fake_drive_service_.get())); |
75 | 75 |
76 provider_.reset(new DriveAppProvider(profile())); | 76 provider_.reset(new DriveAppProvider(profile())); |
77 provider_->SetDriveServiceBridgeForTest( | 77 provider_->SetDriveServiceBridgeForTest( |
78 make_scoped_ptr(new TestDriveServiceBridge(apps_registry_.get())) | 78 make_scoped_ptr(new TestDriveServiceBridge(apps_registry_.get())) |
79 .PassAs<DriveServiceBridge>()); | 79 .PassAs<DriveServiceBridge>()); |
80 | 80 |
81 // The DriveAppProvider in AppListSyncalbeService interferes with the | 81 // The DriveAppProvider in AppListSyncalbeService interferes with the |
82 // test. So resets it. | 82 // test. So resets it. |
83 app_list::AppListSyncableServiceFactory::GetForProfile(profile()) | 83 app_list::AppListSyncableServiceFactory::GetForProfile(profile()) |
84 ->ResetDriveAppProviderForTest(); | 84 ->ResetDriveAppProviderForTest(); |
85 } | 85 } |
86 | 86 |
87 virtual void TearDownOnMainThread() OVERRIDE { | 87 virtual void TearDownOnMainThread() override { |
88 provider_.reset(); | 88 provider_.reset(); |
89 apps_registry_.reset(); | 89 apps_registry_.reset(); |
90 fake_drive_service_.reset(); | 90 fake_drive_service_.reset(); |
91 | 91 |
92 ExtensionBrowserTest::TearDownOnMainThread(); | 92 ExtensionBrowserTest::TearDownOnMainThread(); |
93 } | 93 } |
94 | 94 |
95 const Extension* InstallChromeApp(int expected_change) { | 95 const Extension* InstallChromeApp(int expected_change) { |
96 base::FilePath test_data_path; | 96 base::FilePath test_data_path; |
97 if (!PathService::Get(chrome::DIR_TEST_DATA, &test_data_path)) { | 97 if (!PathService::Get(chrome::DIR_TEST_DATA, &test_data_path)) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 DriveAppMapping* mapping() { return provider_->mapping_.get(); } | 163 DriveAppMapping* mapping() { return provider_->mapping_.get(); } |
164 | 164 |
165 private: | 165 private: |
166 void OnPendingDriveAppConverterCheckTimer() { | 166 void OnPendingDriveAppConverterCheckTimer() { |
167 if (!HasPendingConverters()) | 167 if (!HasPendingConverters()) |
168 runner_->Quit(); | 168 runner_->Quit(); |
169 } | 169 } |
170 | 170 |
171 // extensions::InstallObserver | 171 // extensions::InstallObserver |
172 virtual void OnFinishCrxInstall(const std::string& extension_id, | 172 virtual void OnFinishCrxInstall(const std::string& extension_id, |
173 bool success) OVERRIDE { | 173 bool success) override { |
174 runner_->Quit(); | 174 runner_->Quit(); |
175 } | 175 } |
176 | 176 |
177 scoped_ptr<drive::FakeDriveService> fake_drive_service_; | 177 scoped_ptr<drive::FakeDriveService> fake_drive_service_; |
178 scoped_ptr<drive::DriveAppRegistry> apps_registry_; | 178 scoped_ptr<drive::DriveAppRegistry> apps_registry_; |
179 scoped_ptr<DriveAppProvider> provider_; | 179 scoped_ptr<DriveAppProvider> provider_; |
180 | 180 |
181 base::RepeatingTimer<DriveAppProviderTest> | 181 base::RepeatingTimer<DriveAppProviderTest> |
182 pending_drive_app_converter_check_timer_; | 182 pending_drive_app_converter_check_timer_; |
183 scoped_refptr<content::MessageLoopRunner> runner_; | 183 scoped_refptr<content::MessageLoopRunner> runner_; |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 InstallUserUrlApp(kLaunchUrl); | 451 InstallUserUrlApp(kLaunchUrl); |
452 EXPECT_FALSE(mapping()->IsChromeAppGenerated(url_app_id)); | 452 EXPECT_FALSE(mapping()->IsChromeAppGenerated(url_app_id)); |
453 | 453 |
454 fake_drive_service()->RemoveAppByProductId(kChromeAppId); | 454 fake_drive_service()->RemoveAppByProductId(kChromeAppId); |
455 RefreshDriveAppRegistry(); | 455 RefreshDriveAppRegistry(); |
456 | 456 |
457 // Url app is still present after the Drive app is disconnected. | 457 // Url app is still present after the Drive app is disconnected. |
458 EXPECT_TRUE(ExtensionRegistry::Get(profile())->GetExtensionById( | 458 EXPECT_TRUE(ExtensionRegistry::Get(profile())->GetExtensionById( |
459 url_app_id, ExtensionRegistry::EVERYTHING)); | 459 url_app_id, ExtensionRegistry::EVERYTHING)); |
460 } | 460 } |
OLD | NEW |