| 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/ui/app_list/extension_app_model_builder.h" | 5 #include "chrome/browser/ui/app_list/extension_app_model_builder.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/browser/extensions/extension_function_test_utils.h" | 14 #include "chrome/browser/extensions/extension_function_test_utils.h" |
| 15 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
| 16 #include "chrome/browser/extensions/install_tracker.h" | 16 #include "chrome/browser/extensions/install_tracker.h" |
| 17 #include "chrome/browser/extensions/install_tracker_factory.h" | 17 #include "chrome/browser/extensions/install_tracker_factory.h" |
| 18 #include "chrome/browser/ui/app_list/app_list_test_util.h" | 18 #include "chrome/browser/ui/app_list/app_list_test_util.h" |
| 19 #include "chrome/browser/ui/app_list/test/test_app_list_controller_delegate.h" | 19 #include "chrome/browser/ui/app_list/test/test_app_list_controller_delegate.h" |
| 20 #include "chrome/common/chrome_constants.h" | 20 #include "chrome/common/chrome_constants.h" |
| 21 #include "chrome/common/extensions/extension_constants.h" | 21 #include "chrome/common/extensions/extension_constants.h" |
| 22 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 23 #include "chrome/test/base/testing_profile.h" | 23 #include "chrome/test/base/testing_profile.h" |
| 24 #include "extensions/browser/app_sorting.h" | 24 #include "extensions/browser/app_sorting.h" |
| 25 #include "extensions/browser/extension_prefs.h" | 25 #include "extensions/browser/extension_prefs.h" |
| 26 #include "extensions/browser/extension_registry.h" |
| 26 #include "extensions/browser/uninstall_reason.h" | 27 #include "extensions/browser/uninstall_reason.h" |
| 27 #include "extensions/common/constants.h" | 28 #include "extensions/common/constants.h" |
| 28 #include "extensions/common/extension_set.h" | 29 #include "extensions/common/extension_set.h" |
| 29 #include "extensions/common/manifest.h" | 30 #include "extensions/common/manifest.h" |
| 30 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
| 31 #include "ui/app_list/app_list_item.h" | 32 #include "ui/app_list/app_list_item.h" |
| 32 | 33 |
| 33 namespace { | 34 namespace { |
| 34 | 35 |
| 35 // Get a string of all apps in |model| joined with ','. | 36 // Get a string of all apps in |model| joined with ','. |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 base::Bind(&base::DoNothing), | 177 base::Bind(&base::DoNothing), |
| 177 NULL); | 178 NULL); |
| 178 EXPECT_EQ(std::string("Packaged App 1,Hosted App"), | 179 EXPECT_EQ(std::string("Packaged App 1,Hosted App"), |
| 179 GetModelContent(model_.get())); | 180 GetModelContent(model_.get())); |
| 180 | 181 |
| 181 base::RunLoop().RunUntilIdle(); | 182 base::RunLoop().RunUntilIdle(); |
| 182 } | 183 } |
| 183 | 184 |
| 184 TEST_F(ExtensionAppModelBuilderTest, UninstallTerminatedApp) { | 185 TEST_F(ExtensionAppModelBuilderTest, UninstallTerminatedApp) { |
| 185 const extensions::Extension* app = | 186 const extensions::Extension* app = |
| 186 service_->GetInstalledExtension(kPackagedApp2Id); | 187 registry()->GetInstalledExtension(kPackagedApp2Id); |
| 187 ASSERT_TRUE(app != NULL); | 188 ASSERT_TRUE(app != NULL); |
| 188 | 189 |
| 189 // Simulate an app termination. | 190 // Simulate an app termination. |
| 190 service_->TrackTerminatedExtensionForTest(app); | 191 service_->TrackTerminatedExtensionForTest(app); |
| 191 | 192 |
| 192 service_->UninstallExtension(kPackagedApp2Id, | 193 service_->UninstallExtension(kPackagedApp2Id, |
| 193 extensions::UNINSTALL_REASON_FOR_TESTING, | 194 extensions::UNINSTALL_REASON_FOR_TESTING, |
| 194 base::Bind(&base::DoNothing), | 195 base::Bind(&base::DoNothing), |
| 195 NULL); | 196 NULL); |
| 196 EXPECT_EQ(std::string("Packaged App 1,Hosted App"), | 197 EXPECT_EQ(std::string("Packaged App 1,Hosted App"), |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 extensions::Extension::WAS_INSTALLED_BY_DEFAULT | | 319 extensions::Extension::WAS_INSTALLED_BY_DEFAULT | |
| 319 extensions::Extension::FROM_BOOKMARK, | 320 extensions::Extension::FROM_BOOKMARK, |
| 320 kAppId, | 321 kAppId, |
| 321 &err); | 322 &err); |
| 322 EXPECT_TRUE(err.empty()); | 323 EXPECT_TRUE(err.empty()); |
| 323 | 324 |
| 324 service_->AddExtension(bookmark_app.get()); | 325 service_->AddExtension(bookmark_app.get()); |
| 325 EXPECT_EQ(kDefaultAppCount + 1, model_->top_level_item_list()->item_count()); | 326 EXPECT_EQ(kDefaultAppCount + 1, model_->top_level_item_list()->item_count()); |
| 326 EXPECT_NE(std::string::npos, GetModelContent(model_.get()).find(kAppName)); | 327 EXPECT_NE(std::string::npos, GetModelContent(model_.get()).find(kAppName)); |
| 327 } | 328 } |
| OLD | NEW |