OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/proximity_auth/remote_status_update.h" | 5 #include "components/proximity_auth/remote_status_update.h" |
6 | 6 |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 namespace proximity_auth { | 11 namespace proximity_auth { |
12 namespace { | 12 namespace { |
13 | 13 |
14 // Parses the |json| into a DictionaryValue. | 14 // Parses the |json| into a DictionaryValue. |
15 scoped_ptr<base::DictionaryValue> ParseJson(const std::string& json) { | 15 scoped_ptr<base::DictionaryValue> ParseJson(const std::string& json) { |
16 base::DictionaryValue* as_dictionary; | 16 base::DictionaryValue* as_dictionary; |
17 base::JSONReader::DeprecatedRead(json)->GetAsDictionary(&as_dictionary); | 17 base::JSONReader::Read(json).release()->GetAsDictionary(&as_dictionary); |
18 return make_scoped_ptr(as_dictionary); | 18 return make_scoped_ptr(as_dictionary); |
19 } | 19 } |
20 | 20 |
21 } // namespace | 21 } // namespace |
22 | 22 |
23 // Verify that all valid values can be parsed. | 23 // Verify that all valid values can be parsed. |
24 TEST(ProximityAuthRemoteStatusUpdateTest, Deserialize_ValidStatuses) { | 24 TEST(ProximityAuthRemoteStatusUpdateTest, Deserialize_ValidStatuses) { |
25 { | 25 { |
26 const char kValidJson[] = | 26 const char kValidJson[] = |
27 "{" | 27 "{" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 scoped_ptr<RemoteStatusUpdate> parsed_update = | 181 scoped_ptr<RemoteStatusUpdate> parsed_update = |
182 RemoteStatusUpdate::Deserialize(*ParseJson(kJson)); | 182 RemoteStatusUpdate::Deserialize(*ParseJson(kJson)); |
183 ASSERT_TRUE(parsed_update); | 183 ASSERT_TRUE(parsed_update); |
184 EXPECT_EQ(USER_PRESENT, parsed_update->user_presence); | 184 EXPECT_EQ(USER_PRESENT, parsed_update->user_presence); |
185 EXPECT_EQ(SECURE_SCREEN_LOCK_ENABLED, | 185 EXPECT_EQ(SECURE_SCREEN_LOCK_ENABLED, |
186 parsed_update->secure_screen_lock_state); | 186 parsed_update->secure_screen_lock_state); |
187 EXPECT_EQ(TRUST_AGENT_ENABLED, parsed_update->trust_agent_state); | 187 EXPECT_EQ(TRUST_AGENT_ENABLED, parsed_update->trust_agent_state); |
188 } | 188 } |
189 | 189 |
190 } // namespace proximity_auth | 190 } // namespace proximity_auth |
OLD | NEW |