| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium OS 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 // Unit tests for Service | 5 // Unit tests for Service |
| 6 | 6 |
| 7 #include "cryptohome/service.h" | 7 #include "service.h" |
| 8 | 8 |
| 9 #include <glib.h> | |
| 10 #include <gtest/gtest.h> | 9 #include <gtest/gtest.h> |
| 11 | 10 |
| 12 #include "cryptohome/mock_mount.h" | 11 #include "mock_mount.h" |
| 13 | 12 |
| 14 namespace cryptohome { | 13 namespace cryptohome { |
| 15 using ::testing::Return; | 14 using ::testing::Return; |
| 16 using ::testing::_; | 15 using ::testing::_; |
| 17 | 16 |
| 18 TEST(ServiceInterfaceTests, CheckKeySuccessTest) { | 17 TEST(ServiceInterfaceTests, CheckKeySuccessTest) { |
| 19 MockMount *mount = new MockMount; | 18 MockMount mount; |
| 20 EXPECT_CALL(*mount, TestCredentials(_)) | 19 EXPECT_CALL(mount, TestCredentials(_)) |
| 21 .WillOnce(Return(true)); | 20 .WillOnce(Return(true)); |
| 22 | 21 |
| 23 Service service; | 22 Service service; |
| 24 service.set_mount(mount); // takes ownership. | 23 service.set_mount(&mount); |
| 25 service.Initialize(); | 24 service.Initialize(); |
| 26 gboolean out = FALSE; | 25 gboolean out = FALSE; |
| 27 GError *error = NULL; | 26 GError *error = NULL; |
| 28 | 27 |
| 29 char user[] = "chromeos-user"; | 28 char user[] = "chromeos-user"; |
| 30 char key[] = "274146c6e8886a843ddfea373e2dc71b"; | 29 char key[] = "274146c6e8886a843ddfea373e2dc71b"; |
| 31 EXPECT_EQ(TRUE, service.CheckKey(user, key, &out, &error)); | 30 EXPECT_EQ(TRUE, service.CheckKey(user, key, &out, &error)); |
| 32 EXPECT_EQ(TRUE, out); | 31 EXPECT_EQ(TRUE, out); |
| 33 } | 32 } |
| 34 | 33 |
| 35 // TODO(wad) setup test fixture to create a temp dir | 34 // TODO(wad) setup test fixture to create a temp dir |
| 36 // touch files on Mount/Unmount/IsMounted and | 35 // touch files on Mount/Unmount/IsMounted and |
| 37 // check for goodness. | 36 // check for goodness. |
| 38 | 37 |
| 39 } // namespace cryptohome | 38 } // namespace cryptohome |
| OLD | NEW |