| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/prefs/pref_value_map.h" | 9 #include "base/prefs/pref_value_map.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/prefs/session_startup_pref.h" | 13 #include "chrome/browser/prefs/session_startup_pref.h" |
| 14 #include "chrome/browser/sessions/restore_on_startup_policy_handler.h" | 14 #include "chrome/browser/sessions/restore_on_startup_policy_handler.h" |
| 15 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 16 #include "components/policy/core/browser/configuration_policy_handler.h" | 16 #include "components/policy/core/browser/configuration_policy_handler.h" |
| 17 #include "components/policy/core/browser/policy_error_map.h" | 17 #include "components/policy/core/browser/policy_error_map.h" |
| 18 #include "components/policy/core/common/policy_map.h" | 18 #include "components/policy/core/common/policy_map.h" |
| 19 #include "components/policy/core/common/policy_types.h" |
| 19 #include "grit/components_strings.h" | 20 #include "grit/components_strings.h" |
| 20 #include "policy/policy_constants.h" | 21 #include "policy/policy_constants.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 22 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
| 23 | 24 |
| 24 namespace policy { | 25 namespace policy { |
| 25 | 26 |
| 26 class RestoreOnStartupPolicyHandlerTest : public testing::Test { | 27 class RestoreOnStartupPolicyHandlerTest : public testing::Test { |
| 27 protected: | 28 protected: |
| 28 void SetPolicyValue(const std::string& policy, base::Value* value) { | 29 void SetPolicyValue(const std::string& policy, base::Value* value) { |
| 29 policies_.Set( | 30 policies_.Set( |
| 30 policy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, value, NULL); | 31 policy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 32 value, nullptr); |
| 31 } | 33 } |
| 32 bool CheckPolicySettings() { | 34 bool CheckPolicySettings() { |
| 33 return handler_.CheckPolicySettings(policies_, &errors_); | 35 return handler_.CheckPolicySettings(policies_, &errors_); |
| 34 } | 36 } |
| 35 void ApplyPolicySettings() { | 37 void ApplyPolicySettings() { |
| 36 handler_.ApplyPolicySettings(policies_, &prefs_); | 38 handler_.ApplyPolicySettings(policies_, &prefs_); |
| 37 } | 39 } |
| 38 PolicyErrorMap& errors() { return errors_; } | 40 PolicyErrorMap& errors() { return errors_; } |
| 39 PrefValueMap& prefs() { return prefs_; } | 41 PrefValueMap& prefs() { return prefs_; } |
| 40 | 42 |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 EXPECT_TRUE(prefs().GetValue(prefs::kURLsToRestoreOnStartup, &url_result)); | 284 EXPECT_TRUE(prefs().GetValue(prefs::kURLsToRestoreOnStartup, &url_result)); |
| 283 base::ListValue* url_list_result; | 285 base::ListValue* url_list_result; |
| 284 EXPECT_TRUE(url_result->GetAsList(&url_list_result)); | 286 EXPECT_TRUE(url_result->GetAsList(&url_list_result)); |
| 285 EXPECT_EQ(1U, url_list_result->GetSize()); | 287 EXPECT_EQ(1U, url_list_result->GetSize()); |
| 286 std::string expected_url; | 288 std::string expected_url; |
| 287 EXPECT_TRUE(url_list_result->GetString(0, &expected_url)); | 289 EXPECT_TRUE(url_list_result->GetString(0, &expected_url)); |
| 288 EXPECT_EQ(std::string("http://foo.com"), expected_url); | 290 EXPECT_EQ(std::string("http://foo.com"), expected_url); |
| 289 } | 291 } |
| 290 | 292 |
| 291 } // namespace policy | 293 } // namespace policy |
| OLD | NEW |