Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Side by Side Diff: chromeos/dbus/shill_profile_client_unittest.cc

Issue 10915106: Renaming instances of "flimflam" with "shill", now that we're only (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Upload after merge Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chromeos/dbus/shill_profile_client.cc ('k') | chromeos/dbus/shill_service_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/values.h" 6 #include "base/values.h"
7 #include "chromeos/dbus/flimflam_client_unittest_base.h" 7 #include "chromeos/dbus/shill_client_unittest_base.h"
8 #include "chromeos/dbus/flimflam_profile_client.h" 8 #include "chromeos/dbus/shill_profile_client.h"
9 #include "dbus/message.h" 9 #include "dbus/message.h"
10 #include "dbus/object_path.h" 10 #include "dbus/object_path.h"
11 #include "dbus/values_util.h" 11 #include "dbus/values_util.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "third_party/cros_system_api/dbus/service_constants.h" 13 #include "third_party/cros_system_api/dbus/service_constants.h"
14 14
15 namespace chromeos { 15 namespace chromeos {
16 16
17 namespace { 17 namespace {
18 18
19 const char kDefaultProfilePath[] = "/profile/default"; 19 const char kDefaultProfilePath[] = "/profile/default";
20 const char kExampleEntryPath[] = "example_entry_path"; 20 const char kExampleEntryPath[] = "example_entry_path";
21 21
22 void AppendVariantOfArrayOfStrings(dbus::MessageWriter* writer, 22 void AppendVariantOfArrayOfStrings(dbus::MessageWriter* writer,
23 const std::vector<std::string>& strings) { 23 const std::vector<std::string>& strings) {
24 dbus::MessageWriter variant_writer(NULL); 24 dbus::MessageWriter variant_writer(NULL);
25 writer->OpenVariant("as", &variant_writer); 25 writer->OpenVariant("as", &variant_writer);
26 variant_writer.AppendArrayOfStrings(strings); 26 variant_writer.AppendArrayOfStrings(strings);
27 writer->CloseContainer(&variant_writer); 27 writer->CloseContainer(&variant_writer);
28 } 28 }
29 29
30 } // namespace 30 } // namespace
31 31
32 class FlimflamProfileClientTest : public FlimflamClientUnittestBase { 32 class ShillProfileClientTest : public ShillClientUnittestBase {
33 public: 33 public:
34 FlimflamProfileClientTest() 34 ShillProfileClientTest()
35 : FlimflamClientUnittestBase(flimflam::kFlimflamProfileInterface, 35 : ShillClientUnittestBase(flimflam::kFlimflamProfileInterface,
36 dbus::ObjectPath(kDefaultProfilePath)) { 36 dbus::ObjectPath(kDefaultProfilePath)) {
37 } 37 }
38 38
39 virtual void SetUp() { 39 virtual void SetUp() {
40 FlimflamClientUnittestBase::SetUp(); 40 ShillClientUnittestBase::SetUp();
41 // Create a client with the mock bus. 41 // Create a client with the mock bus.
42 client_.reset(FlimflamProfileClient::Create(REAL_DBUS_CLIENT_IMPLEMENTATION, 42 client_.reset(ShillProfileClient::Create(REAL_DBUS_CLIENT_IMPLEMENTATION,
43 mock_bus_)); 43 mock_bus_));
44 // Run the message loop to run the signal connection result callback. 44 // Run the message loop to run the signal connection result callback.
45 message_loop_.RunAllPending(); 45 message_loop_.RunAllPending();
46 } 46 }
47 47
48 virtual void TearDown() { 48 virtual void TearDown() {
49 FlimflamClientUnittestBase::TearDown(); 49 ShillClientUnittestBase::TearDown();
50 } 50 }
51 51
52 protected: 52 protected:
53 scoped_ptr<FlimflamProfileClient> client_; 53 scoped_ptr<ShillProfileClient> client_;
54 }; 54 };
55 55
56 TEST_F(FlimflamProfileClientTest, PropertyChanged) { 56 TEST_F(ShillProfileClientTest, PropertyChanged) {
57 // Create a signal. 57 // Create a signal.
58 dbus::Signal signal(flimflam::kFlimflamProfileInterface, 58 dbus::Signal signal(flimflam::kFlimflamProfileInterface,
59 flimflam::kMonitorPropertyChanged); 59 flimflam::kMonitorPropertyChanged);
60 dbus::MessageWriter writer(&signal); 60 dbus::MessageWriter writer(&signal);
61 writer.AppendString(flimflam::kEntriesProperty); 61 writer.AppendString(flimflam::kEntriesProperty);
62 AppendVariantOfArrayOfStrings(&writer, 62 AppendVariantOfArrayOfStrings(&writer,
63 std::vector<std::string>(1, kExampleEntryPath)); 63 std::vector<std::string>(1, kExampleEntryPath));
64 64
65 // Set expectations. 65 // Set expectations.
66 base::ListValue value; 66 base::ListValue value;
67 value.Append(base::Value::CreateStringValue(kExampleEntryPath)); 67 value.Append(base::Value::CreateStringValue(kExampleEntryPath));
68 68
69 client_->SetPropertyChangedHandler(dbus::ObjectPath(kDefaultProfilePath), 69 client_->SetPropertyChangedHandler(dbus::ObjectPath(kDefaultProfilePath),
70 base::Bind(&ExpectPropertyChanged, 70 base::Bind(&ExpectPropertyChanged,
71 flimflam::kEntriesProperty, 71 flimflam::kEntriesProperty,
72 &value)); 72 &value));
73 // Run the signal callback. 73 // Run the signal callback.
74 SendPropertyChangedSignal(&signal); 74 SendPropertyChangedSignal(&signal);
75 75
76 // Reset the handler. 76 // Reset the handler.
77 client_->ResetPropertyChangedHandler(dbus::ObjectPath(kDefaultProfilePath)); 77 client_->ResetPropertyChangedHandler(dbus::ObjectPath(kDefaultProfilePath));
78 } 78 }
79 79
80 TEST_F(FlimflamProfileClientTest, GetProperties) { 80 TEST_F(ShillProfileClientTest, GetProperties) {
81 // Create response. 81 // Create response.
82 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 82 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
83 dbus::MessageWriter writer(response.get()); 83 dbus::MessageWriter writer(response.get());
84 dbus::MessageWriter array_writer(NULL); 84 dbus::MessageWriter array_writer(NULL);
85 writer.OpenArray("{sv}", &array_writer); 85 writer.OpenArray("{sv}", &array_writer);
86 dbus::MessageWriter entry_writer(NULL); 86 dbus::MessageWriter entry_writer(NULL);
87 array_writer.OpenDictEntry(&entry_writer); 87 array_writer.OpenDictEntry(&entry_writer);
88 entry_writer.AppendString(flimflam::kEntriesProperty); 88 entry_writer.AppendString(flimflam::kEntriesProperty);
89 AppendVariantOfArrayOfStrings(&entry_writer, 89 AppendVariantOfArrayOfStrings(&entry_writer,
90 std::vector<std::string>(1, kExampleEntryPath)); 90 std::vector<std::string>(1, kExampleEntryPath));
91 array_writer.CloseContainer(&entry_writer); 91 array_writer.CloseContainer(&entry_writer);
92 writer.CloseContainer(&array_writer); 92 writer.CloseContainer(&array_writer);
93 93
94 // Create the expected value. 94 // Create the expected value.
95 base::ListValue* entries = new base::ListValue; 95 base::ListValue* entries = new base::ListValue;
96 entries->Append(base::Value::CreateStringValue(kExampleEntryPath)); 96 entries->Append(base::Value::CreateStringValue(kExampleEntryPath));
97 base::DictionaryValue value; 97 base::DictionaryValue value;
98 value.SetWithoutPathExpansion(flimflam::kEntriesProperty, entries); 98 value.SetWithoutPathExpansion(flimflam::kEntriesProperty, entries);
99 // Set expectations. 99 // Set expectations.
100 PrepareForMethodCall(flimflam::kGetPropertiesFunction, 100 PrepareForMethodCall(flimflam::kGetPropertiesFunction,
101 base::Bind(&ExpectNoArgument), 101 base::Bind(&ExpectNoArgument),
102 response.get()); 102 response.get());
103 // Call method. 103 // Call method.
104 client_->GetProperties(dbus::ObjectPath(kDefaultProfilePath), 104 client_->GetProperties(dbus::ObjectPath(kDefaultProfilePath),
105 base::Bind(&ExpectDictionaryValueResult, &value)); 105 base::Bind(&ExpectDictionaryValueResult, &value));
106 // Run the message loop. 106 // Run the message loop.
107 message_loop_.RunAllPending(); 107 message_loop_.RunAllPending();
108 } 108 }
109 109
110 TEST_F(FlimflamProfileClientTest, GetEntry) { 110 TEST_F(ShillProfileClientTest, GetEntry) {
111 // Create response. 111 // Create response.
112 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 112 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
113 dbus::MessageWriter writer(response.get()); 113 dbus::MessageWriter writer(response.get());
114 dbus::MessageWriter array_writer(NULL); 114 dbus::MessageWriter array_writer(NULL);
115 writer.OpenArray("{sv}", &array_writer); 115 writer.OpenArray("{sv}", &array_writer);
116 dbus::MessageWriter entry_writer(NULL); 116 dbus::MessageWriter entry_writer(NULL);
117 array_writer.OpenDictEntry(&entry_writer); 117 array_writer.OpenDictEntry(&entry_writer);
118 entry_writer.AppendString(flimflam::kTypeProperty); 118 entry_writer.AppendString(flimflam::kTypeProperty);
119 entry_writer.AppendVariantOfString(flimflam::kTypeWifi); 119 entry_writer.AppendVariantOfString(flimflam::kTypeWifi);
120 array_writer.CloseContainer(&entry_writer); 120 array_writer.CloseContainer(&entry_writer);
121 writer.CloseContainer(&array_writer); 121 writer.CloseContainer(&array_writer);
122 122
123 // Create the expected value. 123 // Create the expected value.
124 base::DictionaryValue value; 124 base::DictionaryValue value;
125 value.SetWithoutPathExpansion( 125 value.SetWithoutPathExpansion(
126 flimflam::kTypeProperty, 126 flimflam::kTypeProperty,
127 base::Value::CreateStringValue(flimflam::kTypeWifi)); 127 base::Value::CreateStringValue(flimflam::kTypeWifi));
128 // Set expectations. 128 // Set expectations.
129 PrepareForMethodCall(flimflam::kGetEntryFunction, 129 PrepareForMethodCall(flimflam::kGetEntryFunction,
130 base::Bind(&ExpectStringArgument, kExampleEntryPath), 130 base::Bind(&ExpectStringArgument, kExampleEntryPath),
131 response.get()); 131 response.get());
132 // Call method. 132 // Call method.
133 client_->GetEntry(dbus::ObjectPath(kDefaultProfilePath), 133 client_->GetEntry(dbus::ObjectPath(kDefaultProfilePath),
134 kExampleEntryPath, 134 kExampleEntryPath,
135 base::Bind(&ExpectDictionaryValueResult, &value)); 135 base::Bind(&ExpectDictionaryValueResult, &value));
136 // Run the message loop. 136 // Run the message loop.
137 message_loop_.RunAllPending(); 137 message_loop_.RunAllPending();
138 } 138 }
139 139
140 TEST_F(FlimflamProfileClientTest, DeleteEntry) { 140 TEST_F(ShillProfileClientTest, DeleteEntry) {
141 // Create response. 141 // Create response.
142 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 142 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
143 143
144 // Create the expected value. 144 // Create the expected value.
145 base::DictionaryValue value; 145 base::DictionaryValue value;
146 value.SetWithoutPathExpansion(flimflam::kOfflineModeProperty, 146 value.SetWithoutPathExpansion(flimflam::kOfflineModeProperty,
147 base::Value::CreateBooleanValue(true)); 147 base::Value::CreateBooleanValue(true));
148 // Set expectations. 148 // Set expectations.
149 PrepareForMethodCall(flimflam::kDeleteEntryFunction, 149 PrepareForMethodCall(flimflam::kDeleteEntryFunction,
150 base::Bind(&ExpectStringArgument, kExampleEntryPath), 150 base::Bind(&ExpectStringArgument, kExampleEntryPath),
151 response.get()); 151 response.get());
152 // Call method. 152 // Call method.
153 client_->DeleteEntry(dbus::ObjectPath(kDefaultProfilePath), 153 client_->DeleteEntry(dbus::ObjectPath(kDefaultProfilePath),
154 kExampleEntryPath, 154 kExampleEntryPath,
155 base::Bind(&ExpectNoResultValue)); 155 base::Bind(&ExpectNoResultValue));
156 // Run the message loop. 156 // Run the message loop.
157 message_loop_.RunAllPending(); 157 message_loop_.RunAllPending();
158 } 158 }
159 159
160 } // namespace chromeos 160 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/shill_profile_client.cc ('k') | chromeos/dbus/shill_service_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698