| 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 "ash/launcher/launcher_model.h" | 5 #include "ash/launcher/launcher_model.h" |
| 6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
| 12 #include "chrome/browser/extensions/test_extension_system.h" | 12 #include "chrome/browser/extensions/test_extension_system.h" |
| 13 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" |
| 13 #include "chrome/browser/ui/views/ash/launcher/chrome_launcher_controller.h" | 14 #include "chrome/browser/ui/views/ash/launcher/chrome_launcher_controller.h" |
| 14 #include "chrome/common/extensions/extension.h" | 15 #include "chrome/common/extensions/extension.h" |
| 15 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 16 #include "chrome/test/base/testing_pref_service.h" | 17 #include "chrome/test/base/testing_pref_service.h" |
| 17 #include "chrome/test/base/testing_profile.h" | 18 #include "chrome/test/base/testing_profile.h" |
| 18 #include "content/test/test_browser_thread.h" | 19 #include "content/test/test_browser_thread.h" |
| 19 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 21 | 22 |
| 22 using extensions::Extension; | 23 using extensions::Extension; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 EXPECT_FALSE(launcher_controller.IsAppPinned(extension2_->id())); | 92 EXPECT_FALSE(launcher_controller.IsAppPinned(extension2_->id())); |
| 92 EXPECT_TRUE(launcher_controller.IsAppPinned(extension3_->id())); | 93 EXPECT_TRUE(launcher_controller.IsAppPinned(extension3_->id())); |
| 93 } | 94 } |
| 94 | 95 |
| 95 TEST_F(ChromeLauncherControllerTest, Policy) { | 96 TEST_F(ChromeLauncherControllerTest, Policy) { |
| 96 extension_service_->AddExtension(extension1_.get()); | 97 extension_service_->AddExtension(extension1_.get()); |
| 97 extension_service_->AddExtension(extension3_.get()); | 98 extension_service_->AddExtension(extension3_.get()); |
| 98 | 99 |
| 99 base::ListValue policy_value; | 100 base::ListValue policy_value; |
| 100 base::DictionaryValue* entry1 = new DictionaryValue(); | 101 base::DictionaryValue* entry1 = new DictionaryValue(); |
| 101 entry1->SetString(ChromeLauncherController::kPinnedAppsPrefAppIDPath, | 102 entry1->SetString(ash::kPinnedAppsPrefAppIDPath, extension1_->id()); |
| 102 extension1_->id()); | |
| 103 policy_value.Append(entry1); | 103 policy_value.Append(entry1); |
| 104 base::DictionaryValue* entry2 = new DictionaryValue(); | 104 base::DictionaryValue* entry2 = new DictionaryValue(); |
| 105 entry2->SetString(ChromeLauncherController::kPinnedAppsPrefAppIDPath, | 105 entry2->SetString(ash::kPinnedAppsPrefAppIDPath, extension2_->id()); |
| 106 extension2_->id()); | |
| 107 policy_value.Append(entry2); | 106 policy_value.Append(entry2); |
| 108 profile_.GetTestingPrefService()->SetManagedPref(prefs::kPinnedLauncherApps, | 107 profile_.GetTestingPrefService()->SetManagedPref(prefs::kPinnedLauncherApps, |
| 109 policy_value.DeepCopy()); | 108 policy_value.DeepCopy()); |
| 110 | 109 |
| 111 // Only |extension1_| should get pinned. |extension2_| is specified but not | 110 // Only |extension1_| should get pinned. |extension2_| is specified but not |
| 112 // installed, and |extension3_| is part of the default set, but that shouldn't | 111 // installed, and |extension3_| is part of the default set, but that shouldn't |
| 113 // take effect when the policy override is in place. | 112 // take effect when the policy override is in place. |
| 114 ChromeLauncherController launcher_controller(&profile_, &model_); | 113 ChromeLauncherController launcher_controller(&profile_, &model_); |
| 115 launcher_controller.Init(); | 114 launcher_controller.Init(); |
| 116 EXPECT_EQ(3, model_.item_count()); | 115 EXPECT_EQ(3, model_.item_count()); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 147 |
| 149 EXPECT_TRUE(launcher_controller.IsAppPinned(extension3_->id())); | 148 EXPECT_TRUE(launcher_controller.IsAppPinned(extension3_->id())); |
| 150 EXPECT_TRUE(launcher_controller.IsAppPinned(extension4_->id())); | 149 EXPECT_TRUE(launcher_controller.IsAppPinned(extension4_->id())); |
| 151 | 150 |
| 152 extension_service_->UnloadExtension(extension3_->id(), | 151 extension_service_->UnloadExtension(extension3_->id(), |
| 153 extension_misc::UNLOAD_REASON_UNINSTALL); | 152 extension_misc::UNLOAD_REASON_UNINSTALL); |
| 154 | 153 |
| 155 EXPECT_FALSE(launcher_controller.IsAppPinned(extension3_->id())); | 154 EXPECT_FALSE(launcher_controller.IsAppPinned(extension3_->id())); |
| 156 EXPECT_TRUE(launcher_controller.IsAppPinned(extension4_->id())); | 155 EXPECT_TRUE(launcher_controller.IsAppPinned(extension4_->id())); |
| 157 } | 156 } |
| OLD | NEW |