Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 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 "remoting/host/pairing_registry_delegate_linux.h" | |
| 6 | |
| 7 #include "base/file_util.h" | |
| 8 #include "base/task_runner.h" | |
| 9 #include "testing/gmock/include/gmock/gmock.h" | |
|
Lambros
2013/05/31 18:51:59
Remove gmock.h ?
Jamie
2013/06/19 17:56:44
Done.
| |
| 10 #include "testing/gtest/include/gtest/gtest.h" | |
| 11 | |
| 12 namespace remoting { | |
| 13 namespace protocol { | |
| 14 | |
| 15 bool operator==(const PairingRegistry::PairedClients& a, | |
| 16 const PairingRegistry::PairedClients& b) { | |
| 17 return a.size() == b.size() && std::equal(a.begin(), a.end(), b.begin()); | |
| 18 } | |
| 19 | |
| 20 class PairingRegistryDelegateLinuxTest : public testing::Test { | |
| 21 }; | |
| 22 | |
| 23 TEST_F(PairingRegistryDelegateLinuxTest, SaveAndLoad) { | |
| 24 PairingRegistryDelegateLinux* delegate = | |
| 25 new PairingRegistryDelegateLinux(scoped_refptr<base::TaskRunner>()); | |
| 26 | |
| 27 base::FilePath registry_file; | |
| 28 ASSERT_TRUE(file_util::CreateTemporaryFile(®istry_file)); | |
| 29 delegate->SetFilenameForTesting(registry_file); | |
| 30 | |
| 31 PairingRegistry::PairedClients paired_clients; | |
| 32 PairingRegistry::Pairing pairing = { | |
| 33 base::Time::Now(), | |
| 34 "client_id", | |
| 35 "client_name", | |
| 36 "shared_secret" | |
| 37 }; | |
| 38 paired_clients[pairing.client_id] = pairing; | |
| 39 delegate->SaveOnCurrentThread(paired_clients); | |
| 40 | |
| 41 PairingRegistry::PairedClients paired_clients_loaded = | |
| 42 delegate->LoadOnCurrentThread(); | |
| 43 EXPECT_EQ(paired_clients, paired_clients_loaded); | |
| 44 | |
| 45 file_util::Delete(registry_file, false); | |
| 46 }; | |
| 47 | |
| 48 } // namespace protocol | |
| 49 } // namespace remoting | |
| OLD | NEW |