| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <time.h> | 5 #include <time.h> |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "chromecast/base/serializers.h" | 8 #include "chromecast/crash/linux/crash_testing_utils.h" |
| 9 #include "chromecast/crash/linux/dump_info.h" | 9 #include "chromecast/crash/linux/dump_info.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 namespace chromecast { | 12 namespace chromecast { |
| 13 | 13 |
| 14 namespace { | |
| 15 | |
| 16 scoped_ptr<DumpInfo> CreateDumpInfo(const std::string& json_string) { | |
| 17 scoped_ptr<base::Value> value(DeserializeFromJson(json_string)); | |
| 18 return make_scoped_ptr(new DumpInfo(value.get())); | |
| 19 } | |
| 20 | |
| 21 } // namespace | |
| 22 | |
| 23 TEST(DumpInfoTest, EmptyStringIsNotValid) { | 14 TEST(DumpInfoTest, EmptyStringIsNotValid) { |
| 24 scoped_ptr<DumpInfo> dump_info(CreateDumpInfo("")); | 15 scoped_ptr<DumpInfo> dump_info(CreateDumpInfo("")); |
| 25 ASSERT_FALSE(dump_info->valid()); | 16 ASSERT_FALSE(dump_info->valid()); |
| 26 } | 17 } |
| 27 | 18 |
| 28 TEST(DumpInfoTest, TooFewFieldsIsNotValid) { | 19 TEST(DumpInfoTest, TooFewFieldsIsNotValid) { |
| 29 scoped_ptr<DumpInfo> dump_info(CreateDumpInfo( | 20 scoped_ptr<DumpInfo> dump_info(CreateDumpInfo( |
| 30 "{" | 21 "{" |
| 31 "\"name\": \"name\"," | 22 "\"name\": \"name\"," |
| 32 "\"dump_time\" : \"2001-11-12 18:31:01\"," | 23 "\"dump_time\" : \"2001-11-12 18:31:01\"," |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 "\"prev_app_name\": \"previous_app\"," | 186 "\"prev_app_name\": \"previous_app\"," |
| 196 "\"cur_app_name\": \"current_app\"," | 187 "\"cur_app_name\": \"current_app\"," |
| 197 "\"last_app_name\": \"last_app\"," | 188 "\"last_app_name\": \"last_app\"," |
| 198 "\"release_version\": \"RELEASE\"," | 189 "\"release_version\": \"RELEASE\"," |
| 199 "\"build_number\": \"BUILD_NUMBER\"," | 190 "\"build_number\": \"BUILD_NUMBER\"," |
| 200 "\"hello\": \"extra_field\"" | 191 "\"hello\": \"extra_field\"" |
| 201 "}")); | 192 "}")); |
| 202 ASSERT_FALSE(info->valid()); | 193 ASSERT_FALSE(info->valid()); |
| 203 } | 194 } |
| 204 | 195 |
| 205 } // chromecast | 196 } // namespace chromecast |
| OLD | NEW |