| 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/apps_model_builder.h" | 5 #include "chrome/browser/ui/app_list/apps_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/values.h" | 13 #include "base/values.h" |
| 13 #include "chrome/browser/extensions/extension_function_test_utils.h" | 14 #include "chrome/browser/extensions/extension_function_test_utils.h" |
| 14 #include "chrome/browser/extensions/extension_service_unittest.h" | 15 #include "chrome/browser/extensions/extension_service_unittest.h" |
| 15 #include "chrome/browser/extensions/extension_sorting.h" | 16 #include "chrome/browser/extensions/extension_sorting.h" |
| 16 #include "chrome/common/extensions/extension_constants.h" | 17 #include "chrome/common/extensions/extension_constants.h" |
| 17 #include "chrome/common/extensions/manifest.h" | 18 #include "chrome/common/extensions/manifest.h" |
| 18 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
| 19 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 21 #include "ui/app_list/app_list_item_model.h" | 22 #include "ui/app_list/app_list_item_model.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 TEST_F(AppsModelBuilderTest, Uninstall) { | 154 TEST_F(AppsModelBuilderTest, Uninstall) { |
| 154 scoped_ptr<app_list::AppListModel::Apps> model( | 155 scoped_ptr<app_list::AppListModel::Apps> model( |
| 155 new app_list::AppListModel::Apps); | 156 new app_list::AppListModel::Apps); |
| 156 AppsModelBuilder builder(profile_.get(), model.get(), NULL); | 157 AppsModelBuilder builder(profile_.get(), model.get(), NULL); |
| 157 builder.Build(); | 158 builder.Build(); |
| 158 | 159 |
| 159 service_->UninstallExtension(kPackagedApp2Id, false, NULL); | 160 service_->UninstallExtension(kPackagedApp2Id, false, NULL); |
| 160 EXPECT_EQ(std::string("Packaged App 1,Hosted App"), | 161 EXPECT_EQ(std::string("Packaged App 1,Hosted App"), |
| 161 GetModelContent(model.get())); | 162 GetModelContent(model.get())); |
| 162 | 163 |
| 163 loop_.RunUntilIdle(); | 164 base::RunLoop().RunUntilIdle(); |
| 164 } | 165 } |
| 165 | 166 |
| 166 TEST_F(AppsModelBuilderTest, UninstallTerminatedApp) { | 167 TEST_F(AppsModelBuilderTest, UninstallTerminatedApp) { |
| 167 scoped_ptr<app_list::AppListModel::Apps> model( | 168 scoped_ptr<app_list::AppListModel::Apps> model( |
| 168 new app_list::AppListModel::Apps); | 169 new app_list::AppListModel::Apps); |
| 169 AppsModelBuilder builder(profile_.get(), model.get(), NULL); | 170 AppsModelBuilder builder(profile_.get(), model.get(), NULL); |
| 170 builder.Build(); | 171 builder.Build(); |
| 171 | 172 |
| 172 const extensions::Extension* app = | 173 const extensions::Extension* app = |
| 173 service_->GetInstalledExtension(kPackagedApp2Id); | 174 service_->GetInstalledExtension(kPackagedApp2Id); |
| 174 ASSERT_TRUE(app != NULL); | 175 ASSERT_TRUE(app != NULL); |
| 175 | 176 |
| 176 // Simulate an app termination. | 177 // Simulate an app termination. |
| 177 service_->TrackTerminatedExtensionForTest(app); | 178 service_->TrackTerminatedExtensionForTest(app); |
| 178 | 179 |
| 179 service_->UninstallExtension(kPackagedApp2Id, false, NULL); | 180 service_->UninstallExtension(kPackagedApp2Id, false, NULL); |
| 180 EXPECT_EQ(std::string("Packaged App 1,Hosted App"), | 181 EXPECT_EQ(std::string("Packaged App 1,Hosted App"), |
| 181 GetModelContent(model.get())); | 182 GetModelContent(model.get())); |
| 182 | 183 |
| 183 loop_.RunUntilIdle(); | 184 base::RunLoop().RunUntilIdle(); |
| 184 } | 185 } |
| 185 | 186 |
| 186 TEST_F(AppsModelBuilderTest, OrdinalPrefsChange) { | 187 TEST_F(AppsModelBuilderTest, OrdinalPrefsChange) { |
| 187 scoped_ptr<app_list::AppListModel::Apps> model( | 188 scoped_ptr<app_list::AppListModel::Apps> model( |
| 188 new app_list::AppListModel::Apps); | 189 new app_list::AppListModel::Apps); |
| 189 AppsModelBuilder builder(profile_.get(), model.get(), NULL); | 190 AppsModelBuilder builder(profile_.get(), model.get(), NULL); |
| 190 builder.Build(); | 191 builder.Build(); |
| 191 | 192 |
| 192 ExtensionSorting* sorting = service_->extension_prefs()->extension_sorting(); | 193 ExtensionSorting* sorting = service_->extension_prefs()->extension_sorting(); |
| 193 | 194 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 | 274 |
| 274 // By default, conflicted items are sorted by their app ids. | 275 // By default, conflicted items are sorted by their app ids. |
| 275 EXPECT_EQ(std::string("Hosted App,Packaged App 1,Packaged App 2"), | 276 EXPECT_EQ(std::string("Hosted App,Packaged App 1,Packaged App 2"), |
| 276 GetModelContent(model.get())); | 277 GetModelContent(model.get())); |
| 277 | 278 |
| 278 // Move hosted app between app1 and app2 and it should not crash. | 279 // Move hosted app between app1 and app2 and it should not crash. |
| 279 service_->OnExtensionMoved(kHostedAppId, kPackagedApp1Id, kPackagedApp2Id); | 280 service_->OnExtensionMoved(kHostedAppId, kPackagedApp1Id, kPackagedApp2Id); |
| 280 EXPECT_EQ(std::string("Packaged App 1,Hosted App,Packaged App 2"), | 281 EXPECT_EQ(std::string("Packaged App 1,Hosted App,Packaged App 2"), |
| 281 GetModelContent(model.get())); | 282 GetModelContent(model.get())); |
| 282 } | 283 } |
| OLD | NEW |