OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 <iostream> | 5 #include <iostream> |
6 #include <sstream> | 6 #include <sstream> |
7 | 7 |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "chromeos/dbus/dbus_thread_manager.h" | 9 #include "chromeos/dbus/dbus_thread_manager.h" |
10 #include "chromeos/dbus/mock_dbus_thread_manager.h" | 10 #include "chromeos/dbus/mock_dbus_thread_manager.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 } | 72 } |
73 | 73 |
74 void AddEntry(const std::string& profile_path, | 74 void AddEntry(const std::string& profile_path, |
75 const std::string& entry_path, | 75 const std::string& entry_path, |
76 const base::DictionaryValue& entry) { | 76 const base::DictionaryValue& entry) { |
77 base::DictionaryValue* entries = NULL; | 77 base::DictionaryValue* entries = NULL; |
78 profile_entries_.GetDictionaryWithoutPathExpansion(profile_path, &entries); | 78 profile_entries_.GetDictionaryWithoutPathExpansion(profile_path, &entries); |
79 ASSERT_TRUE(entries); | 79 ASSERT_TRUE(entries); |
80 | 80 |
81 base::DictionaryValue* new_entry = entry.DeepCopy(); | 81 base::DictionaryValue* new_entry = entry.DeepCopy(); |
82 new_entry->SetStringWithoutPathExpansion(flimflam::kProfileProperty, | 82 new_entry->SetStringWithoutPathExpansion(shill::kProfileProperty, |
83 profile_path); | 83 profile_path); |
84 entries->SetWithoutPathExpansion(entry_path, new_entry); | 84 entries->SetWithoutPathExpansion(entry_path, new_entry); |
85 } | 85 } |
86 | 86 |
87 void GetProperties(const dbus::ObjectPath& profile_path, | 87 void GetProperties(const dbus::ObjectPath& profile_path, |
88 const DictionaryValueCallbackWithoutStatus& callback, | 88 const DictionaryValueCallbackWithoutStatus& callback, |
89 const ErrorCallback& error_callback) { | 89 const ErrorCallback& error_callback) { |
90 base::DictionaryValue* entries = NULL; | 90 base::DictionaryValue* entries = NULL; |
91 profile_entries_.GetDictionaryWithoutPathExpansion(profile_path.value(), | 91 profile_entries_.GetDictionaryWithoutPathExpansion(profile_path.value(), |
92 &entries); | 92 &entries); |
93 ASSERT_TRUE(entries); | 93 ASSERT_TRUE(entries); |
94 | 94 |
95 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue); | 95 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue); |
96 base::ListValue* entry_paths = new base::ListValue; | 96 base::ListValue* entry_paths = new base::ListValue; |
97 result->SetWithoutPathExpansion(flimflam::kEntriesProperty, | 97 result->SetWithoutPathExpansion(shill::kEntriesProperty, entry_paths); |
98 entry_paths); | |
99 for (base::DictionaryValue::Iterator it(*entries); !it.IsAtEnd(); | 98 for (base::DictionaryValue::Iterator it(*entries); !it.IsAtEnd(); |
100 it.Advance()) { | 99 it.Advance()) { |
101 entry_paths->AppendString(it.key()); | 100 entry_paths->AppendString(it.key()); |
102 } | 101 } |
103 | 102 |
104 ASSERT_GT(profile_to_user_.count(profile_path.value()), 0UL); | 103 ASSERT_GT(profile_to_user_.count(profile_path.value()), 0UL); |
105 const std::string& userhash = profile_to_user_[profile_path.value()]; | 104 const std::string& userhash = profile_to_user_[profile_path.value()]; |
106 result->SetStringWithoutPathExpansion(shill::kUserHashProperty, userhash); | 105 result->SetStringWithoutPathExpansion(shill::kUserHashProperty, userhash); |
107 | 106 |
108 callback.Run(*result); | 107 callback.Run(*result); |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 kUser1ProfilePath, | 404 kUser1ProfilePath, |
406 "old_entry_path"); | 405 "old_entry_path"); |
407 | 406 |
408 scoped_ptr<base::DictionaryValue> expected_shill_properties = | 407 scoped_ptr<base::DictionaryValue> expected_shill_properties = |
409 test_utils::ReadTestDictionary( | 408 test_utils::ReadTestDictionary( |
410 "policy/shill_policy_on_unmanaged_user_wifi1.json"); | 409 "policy/shill_policy_on_unmanaged_user_wifi1.json"); |
411 | 410 |
412 // The passphrase isn't sent again, because it's configured by the user and | 411 // The passphrase isn't sent again, because it's configured by the user and |
413 // Shill doesn't sent it on GetProperties calls. | 412 // Shill doesn't sent it on GetProperties calls. |
414 expected_shill_properties->RemoveWithoutPathExpansion( | 413 expected_shill_properties->RemoveWithoutPathExpansion( |
415 flimflam::kPassphraseProperty, NULL); | 414 shill::kPassphraseProperty, NULL); |
416 | 415 |
417 EXPECT_CALL(mock_profile_client_, | 416 EXPECT_CALL(mock_profile_client_, |
418 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _)); | 417 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _)); |
419 | 418 |
420 EXPECT_CALL( | 419 EXPECT_CALL( |
421 mock_profile_client_, | 420 mock_profile_client_, |
422 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _)); | 421 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _)); |
423 | 422 |
424 EXPECT_CALL( | 423 EXPECT_CALL( |
425 mock_profile_client_, | 424 mock_profile_client_, |
(...skipping 15 matching lines...) Expand all Loading... |
441 kUser1ProfilePath, | 440 kUser1ProfilePath, |
442 "old_entry_path"); | 441 "old_entry_path"); |
443 | 442 |
444 scoped_ptr<base::DictionaryValue> expected_shill_properties = | 443 scoped_ptr<base::DictionaryValue> expected_shill_properties = |
445 test_utils::ReadTestDictionary( | 444 test_utils::ReadTestDictionary( |
446 "policy/shill_policy_on_unmanaged_user_wifi1.json"); | 445 "policy/shill_policy_on_unmanaged_user_wifi1.json"); |
447 | 446 |
448 // The passphrase isn't sent again, because it's configured by the user and | 447 // The passphrase isn't sent again, because it's configured by the user and |
449 // Shill doesn't sent it on GetProperties calls. | 448 // Shill doesn't sent it on GetProperties calls. |
450 expected_shill_properties->RemoveWithoutPathExpansion( | 449 expected_shill_properties->RemoveWithoutPathExpansion( |
451 flimflam::kPassphraseProperty, NULL); | 450 shill::kPassphraseProperty, NULL); |
452 | 451 |
453 EXPECT_CALL(mock_profile_client_, | 452 EXPECT_CALL(mock_profile_client_, |
454 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _)); | 453 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _)); |
455 | 454 |
456 EXPECT_CALL( | 455 EXPECT_CALL( |
457 mock_profile_client_, | 456 mock_profile_client_, |
458 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _)); | 457 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _)); |
459 | 458 |
460 EXPECT_CALL(mock_manager_client_, | 459 EXPECT_CALL(mock_manager_client_, |
461 ConfigureServiceForProfile( | 460 ConfigureServiceForProfile( |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 ConfigureServiceForProfile( | 564 ConfigureServiceForProfile( |
566 dbus::ObjectPath(kUser1ProfilePath), | 565 dbus::ObjectPath(kUser1ProfilePath), |
567 IsEqualTo(expected_shill_properties.get()), | 566 IsEqualTo(expected_shill_properties.get()), |
568 _, _)); | 567 _, _)); |
569 | 568 |
570 InitializeStandardProfiles(); | 569 InitializeStandardProfiles(); |
571 message_loop_.RunUntilIdle(); | 570 message_loop_.RunUntilIdle(); |
572 } | 571 } |
573 | 572 |
574 } // namespace chromeos | 573 } // namespace chromeos |
OLD | NEW |