summaryrefslogtreecommitdiff
path: root/src/components/resumption
diff options
context:
space:
mode:
authorKozoriz <kozorizandriy@gmail.com>2016-03-24 10:13:18 +0200
committerKozoriz <kozorizandriy@gmail.com>2016-03-31 19:45:44 +0300
commit0881fce59b5455883283574b52af07556ee558d1 (patch)
tree7c6755e51749551398bc98b78b0d33e526d507f7 /src/components/resumption
parente3d47f6bc697af0b8593550389e82b5f2d01cb23 (diff)
downloadsdl_core-0881fce59b5455883283574b52af07556ee558d1.tar.gz
Changes after review
Fixed LastState tests SharedPtr changed to auto_ptr in some cases Corrected consts in some cases
Diffstat (limited to 'src/components/resumption')
-rw-r--r--src/components/resumption/test/last_state_test.cc46
1 files changed, 21 insertions, 25 deletions
diff --git a/src/components/resumption/test/last_state_test.cc b/src/components/resumption/test/last_state_test.cc
index 09582a38c8..31bb26567b 100644
--- a/src/components/resumption/test/last_state_test.cc
+++ b/src/components/resumption/test/last_state_test.cc
@@ -32,9 +32,12 @@
#include "gtest/gtest.h"
#include <string>
+#include <memory>
#include "resumption/last_state.h"
#include "config_profile/profile.h"
#include "utils/file_system.h"
+#include "utils/shared_ptr.h"
+#include "utils/make_shared.h"
namespace test {
namespace components {
@@ -45,41 +48,36 @@ using namespace ::Json;
class LastStateTest : public ::testing::Test {
protected:
- LastStateTest():last_state_("app_storage_folder",
- "app_info_storage"){}
- virtual void SetUp() {
- ASSERT_TRUE(::file_system::CreateFile("./app_info.dat"));
- ::profile::Profile::instance()->UpdateValues();
+ void SetUp() OVERRIDE {
+ file_system::DeleteFile("./app_info_storage");
+ last_state_ = std::auto_ptr<resumption::LastState>(
+ new resumption::LastState("app_storage_folder", "app_info_storage"));
+ ASSERT_TRUE(file_system::CreateFile("./app_info.dat"));
+ profile::Profile::instance()->UpdateValues();
}
- virtual void TearDown() {
- EXPECT_TRUE(::file_system::DeleteFile("./app_info.dat"));
+ void TearDown() OVERRIDE {
+ EXPECT_TRUE(file_system::DeleteFile("./app_info.dat"));
}
- resumption::LastState last_state_;
+ std::auto_ptr<resumption::LastState> last_state_;
};
TEST_F(LastStateTest, Basic) {
- Value& dictionary = last_state_.dictionary;
- const std::string empty_dictionary =
- "{\n \"TransportManager\" : {\n \"BluetoothAdapter\" : {\n "
- " \"devices\" : \"bluetooth_device\"\n },\n \"TcpAdapter\" : "
- "{\n \"devices\" : {\n \"name\" : \"test_device\"\n "
- " }\n }\n },\n \"resumption\" : {\n "
- "\"last_ign_off_time\" : null,\n \"resume_app_list\" : null\n "
- "}\n}\n";
+ Value& dictionary = last_state_->dictionary;
+ const std::string empty_dictionary = "null\n";
EXPECT_EQ(empty_dictionary, dictionary.toStyledString());
}
TEST_F(LastStateTest, SetGetData) {
{
- Value& dictionary = last_state_.dictionary;
+ Value& dictionary = last_state_->dictionary;
Value bluetooth_info = dictionary["TransportManager"]["BluetoothAdapter"];
- const std::string empty_bluetooth = "{\n \"devices\" : \"bluetooth_device\"\n}\n";
+ const std::string empty_bluetooth = "null\n";
EXPECT_EQ(empty_bluetooth, bluetooth_info.toStyledString());
Value tcp_adapter_info =
dictionary["TransportManager"]["TcpAdapter"]["devices"];
- const std::string no_devices = "{\n \"name\" : \"test_device\"\n}\n";
+ const std::string no_devices = "null\n";
EXPECT_EQ(no_devices, tcp_adapter_info.toStyledString());
Value resumption_time = dictionary["resumption"]["last_ign_off_time"];
@@ -92,15 +90,13 @@ TEST_F(LastStateTest, SetGetData) {
test_value["name"] = "test_device";
last_state_
- .dictionary["TransportManager"]["TcpAdapter"]["devices"] = test_value;
+ ->dictionary["TransportManager"]["TcpAdapter"]["devices"] = test_value;
last_state_
- .dictionary["TransportManager"]["BluetoothAdapter"]["devices"] =
+ ->dictionary["TransportManager"]["BluetoothAdapter"]["devices"] =
"bluetooth_device";
- last_state_.SaveToFileSystem();
+ last_state_->SaveToFileSystem();
}
-
- Value& dictionary = last_state_.dictionary;
-
+ Value& dictionary = last_state_->dictionary;
Value bluetooth_info = dictionary["TransportManager"]["BluetoothAdapter"];
Value tcp_adapter_info = dictionary["TransportManager"]["TcpAdapter"];
EXPECT_EQ("{\n \"devices\" : \"bluetooth_device\"\n}\n",