| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "components/sessions/core/session_backend.h" | 5 #include "components/sessions/core/session_backend.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 memcpy(command->contents(), data.data.c_str(), data.data.size()); | 33 memcpy(command->contents(), data.data.c_str(), data.data.size()); |
| 34 return command; | 34 return command; |
| 35 } | 35 } |
| 36 | 36 |
| 37 } // namespace | 37 } // namespace |
| 38 | 38 |
| 39 class SessionBackendTest : public testing::Test { | 39 class SessionBackendTest : public testing::Test { |
| 40 protected: | 40 protected: |
| 41 void SetUp() override { | 41 void SetUp() override { |
| 42 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 42 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 43 path_ = temp_dir_.path().Append(FILE_PATH_LITERAL("SessionTestDirs")); | 43 path_ = temp_dir_.GetPath().Append(FILE_PATH_LITERAL("SessionTestDirs")); |
| 44 base::CreateDirectory(path_); | 44 base::CreateDirectory(path_); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void AssertCommandEqualsData(const TestData& data, | 47 void AssertCommandEqualsData(const TestData& data, |
| 48 sessions::SessionCommand* command) { | 48 sessions::SessionCommand* command) { |
| 49 EXPECT_EQ(data.command_id, command->id()); | 49 EXPECT_EQ(data.command_id, command->id()); |
| 50 EXPECT_EQ(data.data.size(), command->size()); | 50 EXPECT_EQ(data.data.size(), command->size()); |
| 51 EXPECT_TRUE( | 51 EXPECT_TRUE( |
| 52 memcmp(command->contents(), data.data.c_str(), command->size()) == 0); | 52 memcmp(command->contents(), data.data.c_str(), command->size()) == 0); |
| 53 } | 53 } |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 backend->ReadLastSessionCommandsImpl(&commands); | 205 backend->ReadLastSessionCommandsImpl(&commands); |
| 206 | 206 |
| 207 // And make sure we get back the expected data. | 207 // And make sure we get back the expected data. |
| 208 ASSERT_EQ(1U, commands.size()); | 208 ASSERT_EQ(1U, commands.size()); |
| 209 AssertCommandEqualsData(second_data, commands[0]); | 209 AssertCommandEqualsData(second_data, commands[0]); |
| 210 | 210 |
| 211 commands.clear(); | 211 commands.clear(); |
| 212 } | 212 } |
| 213 | 213 |
| 214 } // namespace sessions | 214 } // namespace sessions |
| OLD | NEW |