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/sync/test/integration/extension_settings_helper.h" | 5 #include "chrome/browser/sync/test/integration/extension_settings_helper.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 namespace { | 29 namespace { |
30 | 30 |
31 std::string ToJson(const Value& value) { | 31 std::string ToJson(const Value& value) { |
32 std::string json; | 32 std::string json; |
33 base::JSONWriter::WriteWithOptions(&value, | 33 base::JSONWriter::WriteWithOptions(&value, |
34 base::JSONWriter::OPTIONS_PRETTY_PRINT, | 34 base::JSONWriter::OPTIONS_PRETTY_PRINT, |
35 &json); | 35 &json); |
36 return json; | 36 return json; |
37 } | 37 } |
38 | 38 |
39 void GetAllSettingsOnFileThread( | 39 void GetAllSettingsOnFileThread(DictionaryValue* out, |
40 scoped_ptr<DictionaryValue>* out, | 40 base::WaitableEvent* signal, |
41 base::WaitableEvent* signal, | 41 ValueStore* storage) { |
42 ValueStore* storage) { | |
43 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 42 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
44 out->swap(storage->Get()->settings()); | 43 out->Swap(&storage->Get()->settings()); |
45 signal->Signal(); | 44 signal->Signal(); |
46 } | 45 } |
47 | 46 |
48 scoped_ptr<DictionaryValue> GetAllSettings( | 47 scoped_ptr<DictionaryValue> GetAllSettings( |
49 Profile* profile, const std::string& id) { | 48 Profile* profile, const std::string& id) { |
50 base::WaitableEvent signal(false, false); | 49 base::WaitableEvent signal(false, false); |
51 scoped_ptr<DictionaryValue> settings; | 50 scoped_ptr<DictionaryValue> settings(new DictionaryValue()); |
52 profile->GetExtensionService()->settings_frontend()->RunWithStorage( | 51 profile->GetExtensionService()->settings_frontend()->RunWithStorage( |
53 id, | 52 id, |
54 extensions::settings_namespace::SYNC, | 53 extensions::settings_namespace::SYNC, |
55 base::Bind(&GetAllSettingsOnFileThread, &settings, &signal)); | 54 base::Bind(&GetAllSettingsOnFileThread, settings.get(), &signal)); |
56 signal.Wait(); | 55 signal.Wait(); |
57 return settings.Pass(); | 56 return settings.Pass(); |
58 } | 57 } |
59 | 58 |
60 bool AreSettingsSame(Profile* expected_profile, Profile* actual_profile) { | 59 bool AreSettingsSame(Profile* expected_profile, Profile* actual_profile) { |
61 const ExtensionSet* extensions = | 60 const ExtensionSet* extensions = |
62 expected_profile->GetExtensionService()->extensions(); | 61 expected_profile->GetExtensionService()->extensions(); |
63 if (extensions->size() != | 62 if (extensions->size() != |
64 actual_profile->GetExtensionService()->extensions()->size()) { | 63 actual_profile->GetExtensionService()->extensions()->size()) { |
65 ADD_FAILURE(); | 64 ADD_FAILURE(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 bool all_profiles_same = true; | 112 bool all_profiles_same = true; |
114 for (int i = 0; i < test()->num_clients(); ++i) { | 113 for (int i = 0; i < test()->num_clients(); ++i) { |
115 // &= so that all profiles are tested; analogous to EXPECT over ASSERT. | 114 // &= so that all profiles are tested; analogous to EXPECT over ASSERT. |
116 all_profiles_same &= | 115 all_profiles_same &= |
117 AreSettingsSame(test()->verifier(), test()->GetProfile(i)); | 116 AreSettingsSame(test()->verifier(), test()->GetProfile(i)); |
118 } | 117 } |
119 return all_profiles_same; | 118 return all_profiles_same; |
120 } | 119 } |
121 | 120 |
122 } // namespace extension_settings_helper | 121 } // namespace extension_settings_helper |
OLD | NEW |