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 <algorithm> | 5 #include <algorithm> |
6 #include <map> | 6 #include <map> |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/pickle.h" | 11 #include "base/pickle.h" |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
13 #include "base/synchronization/waitable_event.h" | 13 #include "base/synchronization/waitable_event.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "chrome/browser/password_manager/native_backend_kwallet_x.h" | 15 #include "chrome/browser/password_manager/native_backend_kwallet_x.h" |
16 #include "chrome/browser/prefs/pref_service.h" | 16 #include "chrome/browser/prefs/pref_service.h" |
17 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
18 #include "chrome/test/base/testing_profile.h" | 18 #include "chrome/test/base/testing_profile.h" |
19 #include "content/test/test_browser_thread.h" | 19 #include "content/test/test_browser_thread.h" |
20 #include "dbus/message.h" | 20 #include "dbus/message.h" |
21 #include "dbus/mock_bus.h" | 21 #include "dbus/mock_bus.h" |
22 #include "dbus/mock_object_proxy.h" | 22 #include "dbus/mock_object_proxy.h" |
| 23 #include "dbus/object_path.h" |
23 #include "dbus/object_proxy.h" | 24 #include "dbus/object_proxy.h" |
24 #include "testing/gmock/include/gmock/gmock.h" | 25 #include "testing/gmock/include/gmock/gmock.h" |
25 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
26 | 27 |
27 using content::BrowserThread; | 28 using content::BrowserThread; |
28 using testing::_; | 29 using testing::_; |
29 using testing::Invoke; | 30 using testing::Invoke; |
30 using testing::Return; | 31 using testing::Return; |
31 using webkit::forms::PasswordForm; | 32 using webkit::forms::PasswordForm; |
32 | 33 |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 form_isc_.submit_element = UTF8ToUTF16("login"); | 219 form_isc_.submit_element = UTF8ToUTF16("login"); |
219 form_isc_.signon_realm = "ISC"; | 220 form_isc_.signon_realm = "ISC"; |
220 | 221 |
221 dbus::Bus::Options options; | 222 dbus::Bus::Options options; |
222 options.bus_type = dbus::Bus::SESSION; | 223 options.bus_type = dbus::Bus::SESSION; |
223 mock_session_bus_ = new dbus::MockBus(options); | 224 mock_session_bus_ = new dbus::MockBus(options); |
224 | 225 |
225 mock_klauncher_proxy_ = | 226 mock_klauncher_proxy_ = |
226 new dbus::MockObjectProxy(mock_session_bus_.get(), | 227 new dbus::MockObjectProxy(mock_session_bus_.get(), |
227 "org.kde.klauncher", | 228 "org.kde.klauncher", |
228 "/KLauncher"); | 229 dbus::ObjectPath("/KLauncher")); |
229 EXPECT_CALL(*mock_klauncher_proxy_, | 230 EXPECT_CALL(*mock_klauncher_proxy_, |
230 CallMethodAndBlock(_, _)) | 231 CallMethodAndBlock(_, _)) |
231 .WillRepeatedly(Invoke(this, | 232 .WillRepeatedly(Invoke(this, |
232 &NativeBackendKWalletTest::KLauncherMethodCall)); | 233 &NativeBackendKWalletTest::KLauncherMethodCall)); |
233 | 234 |
234 mock_kwallet_proxy_ = | 235 mock_kwallet_proxy_ = |
235 new dbus::MockObjectProxy(mock_session_bus_.get(), | 236 new dbus::MockObjectProxy(mock_session_bus_.get(), |
236 "org.kde.kwalletd", | 237 "org.kde.kwalletd", |
237 "/modules/kwalletd"); | 238 dbus::ObjectPath("/modules/kwalletd")); |
238 EXPECT_CALL(*mock_kwallet_proxy_, | 239 EXPECT_CALL(*mock_kwallet_proxy_, |
239 CallMethodAndBlock(_, _)) | 240 CallMethodAndBlock(_, _)) |
240 .WillRepeatedly(Invoke(this, | 241 .WillRepeatedly(Invoke(this, |
241 &NativeBackendKWalletTest::KWalletMethodCall)); | 242 &NativeBackendKWalletTest::KWalletMethodCall)); |
242 | 243 |
243 EXPECT_CALL(*mock_session_bus_, GetObjectProxy( | 244 EXPECT_CALL(*mock_session_bus_, GetObjectProxy( |
244 "org.kde.klauncher", | 245 "org.kde.klauncher", |
245 "/KLauncher")) | 246 dbus::ObjectPath("/KLauncher"))) |
246 .WillRepeatedly(Return(mock_klauncher_proxy_.get())); | 247 .WillRepeatedly(Return(mock_klauncher_proxy_.get())); |
247 EXPECT_CALL(*mock_session_bus_, GetObjectProxy( | 248 EXPECT_CALL(*mock_session_bus_, GetObjectProxy( |
248 "org.kde.kwalletd", | 249 "org.kde.kwalletd", |
249 "/modules/kwalletd")) | 250 dbus::ObjectPath("/modules/kwalletd"))) |
250 .WillRepeatedly(Return(mock_kwallet_proxy_.get())); | 251 .WillRepeatedly(Return(mock_kwallet_proxy_.get())); |
251 | 252 |
252 EXPECT_CALL(*mock_session_bus_, | 253 EXPECT_CALL(*mock_session_bus_, |
253 ShutdownAndBlock()).WillOnce(Return()).WillRepeatedly(Return()); | 254 ShutdownAndBlock()).WillOnce(Return()).WillRepeatedly(Return()); |
254 } | 255 } |
255 | 256 |
256 void NativeBackendKWalletTest::TearDown() { | 257 void NativeBackendKWalletTest::TearDown() { |
257 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 258 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
258 MessageLoop::current()->Run(); | 259 MessageLoop::current()->Run(); |
259 db_thread_.Stop(); | 260 db_thread_.Stop(); |
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1003 | 1004 |
1004 RunDBThread(); | 1005 RunDBThread(); |
1005 | 1006 |
1006 // The other two copies of the password in different profiles should remain. | 1007 // The other two copies of the password in different profiles should remain. |
1007 CheckPasswordForms("Chrome Form Data", expected); | 1008 CheckPasswordForms("Chrome Form Data", expected); |
1008 CheckPasswordForms("Chrome Form Data (42)", expected); | 1009 CheckPasswordForms("Chrome Form Data (42)", expected); |
1009 expected.clear(); | 1010 expected.clear(); |
1010 CheckPasswordForms("Chrome Form Data (24)", expected); | 1011 CheckPasswordForms("Chrome Form Data (24)", expected); |
1011 } | 1012 } |
1012 } | 1013 } |
OLD | NEW |