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/chromeos/settings/cros_settings.h" |
| 6 |
5 #include <map> | 7 #include <map> |
| 8 #include <memory> |
6 #include <string> | 9 #include <string> |
7 | 10 |
8 #include "base/bind.h" | 11 #include "base/bind.h" |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
11 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
12 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
13 #include "base/values.h" | 15 #include "base/values.h" |
14 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 16 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
15 #include "chrome/browser/chromeos/settings/cros_settings.h" | |
16 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 17 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
17 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" | 18 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" |
18 #include "chrome/test/base/scoped_testing_local_state.h" | 19 #include "chrome/test/base/scoped_testing_local_state.h" |
19 #include "chrome/test/base/testing_browser_process.h" | 20 #include "chrome/test/base/testing_browser_process.h" |
20 #include "chromeos/settings/cros_settings_names.h" | 21 #include "chromeos/settings/cros_settings_names.h" |
21 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 22 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
22 #include "content/public/test/test_browser_thread.h" | 23 #include "content/public/test/test_browser_thread.h" |
23 #include "policy/proto/device_management_backend.pb.h" | 24 #include "policy/proto/device_management_backend.pb.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
25 | 26 |
(...skipping 18 matching lines...) Expand all Loading... |
44 | 45 |
45 void FetchPref(const std::string& pref) { | 46 void FetchPref(const std::string& pref) { |
46 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 47 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
47 if (expected_props_.find(pref) == expected_props_.end()) | 48 if (expected_props_.find(pref) == expected_props_.end()) |
48 return; | 49 return; |
49 | 50 |
50 if (CrosSettingsProvider::TRUSTED == | 51 if (CrosSettingsProvider::TRUSTED == |
51 settings_.PrepareTrustedValues( | 52 settings_.PrepareTrustedValues( |
52 base::Bind(&CrosSettingsTest::FetchPref, | 53 base::Bind(&CrosSettingsTest::FetchPref, |
53 weak_factory_.GetWeakPtr(), pref))) { | 54 weak_factory_.GetWeakPtr(), pref))) { |
54 scoped_ptr<base::Value> expected_value( | 55 std::unique_ptr<base::Value> expected_value( |
55 expected_props_.find(pref)->second); | 56 expected_props_.find(pref)->second); |
56 const base::Value* pref_value = settings_.GetPref(pref); | 57 const base::Value* pref_value = settings_.GetPref(pref); |
57 if (expected_value.get()) { | 58 if (expected_value.get()) { |
58 ASSERT_TRUE(pref_value); | 59 ASSERT_TRUE(pref_value); |
59 ASSERT_TRUE(expected_value->Equals(pref_value)); | 60 ASSERT_TRUE(expected_value->Equals(pref_value)); |
60 } else { | 61 } else { |
61 ASSERT_FALSE(pref_value); | 62 ASSERT_FALSE(pref_value); |
62 } | 63 } |
63 expected_props_.erase(pref); | 64 expected_props_.erase(pref); |
64 } | 65 } |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 EXPECT_TRUE(wildcard_match); | 260 EXPECT_TRUE(wildcard_match); |
260 EXPECT_TRUE(cs->FindEmailInList( | 261 EXPECT_TRUE(cs->FindEmailInList( |
261 kAccountsPrefUsers, "user@example.com", &wildcard_match)); | 262 kAccountsPrefUsers, "user@example.com", &wildcard_match)); |
262 EXPECT_FALSE(wildcard_match); | 263 EXPECT_FALSE(wildcard_match); |
263 EXPECT_TRUE(cs->FindEmailInList( | 264 EXPECT_TRUE(cs->FindEmailInList( |
264 kAccountsPrefUsers, "*@example.com", &wildcard_match)); | 265 kAccountsPrefUsers, "*@example.com", &wildcard_match)); |
265 EXPECT_TRUE(wildcard_match); | 266 EXPECT_TRUE(wildcard_match); |
266 } | 267 } |
267 | 268 |
268 } // namespace chromeos | 269 } // namespace chromeos |
OLD | NEW |