OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include <string.h> |
| 6 |
| 7 #include "chrome/browser/password_manager/keyring_proxy/gnome_keyring_loader.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 |
| 10 namespace keyring_proxy { |
| 11 |
| 12 class TestKeyringLoader : public GnomeKeyringLoader { |
| 13 public: |
| 14 // Promote members to be public for testing. |
| 15 using GnomeKeyringLoader::LoadGnomeKeyring; |
| 16 #define GNOME_KEYRING_USE_KEYRING_METHOD(name) \ |
| 17 using GnomeKeyringLoader::gnome_keyring_##name; |
| 18 GNOME_KEYRING_FOR_EACH_FUNC(GNOME_KEYRING_USE_KEYRING_METHOD) |
| 19 #undef GNOME_KEYRING_USE_KEYRING_METHOD |
| 20 }; |
| 21 |
| 22 TEST(GnomeKeyringLoaderTest, LoadsGnomeKeyring) { |
| 23 TestKeyringLoader loader; |
| 24 EXPECT_TRUE(loader.LoadGnomeKeyring()); |
| 25 // Since the test is linked directly with libgnomekeyring, we can compare the |
| 26 // results of dynamically loading it against the directly-linked symbols. But |
| 27 // this only works correctly when compiled with -fPIC as otherwise the linked |
| 28 // symbols go through local PLT stubs which makes the addresses not match. |
| 29 #if defined(__PIC__) |
| 30 #define GNOME_KEYRING_TEST_KEYRING_METHOD(name) \ |
| 31 EXPECT_EQ(&::gnome_keyring_##name, loader.gnome_keyring_##name); |
| 32 GNOME_KEYRING_FOR_EACH_FUNC(GNOME_KEYRING_TEST_KEYRING_METHOD) |
| 33 #undef GNOME_KEYRING_TEST_KEYRING_METHOD |
| 34 #endif |
| 35 } |
| 36 |
| 37 } // namespace keyring_proxy |
OLD | NEW |