| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/extensions/api/dial/dial_device_data.h" | 5 #include "chrome/browser/media/router/discovery/dial/dial_device_data.h" |
| 6 #include "chrome/common/extensions/api/dial.h" | 6 #include "chrome/common/extensions/api/dial.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 namespace extensions { | 9 namespace media_router { |
| 10 namespace api { | |
| 11 namespace dial { | |
| 12 | 10 |
| 13 namespace { | 11 namespace { |
| 14 | 12 |
| 15 // Asserts equality between the two objects. | 13 // Asserts equality between the two objects. |
| 16 void ExpectEqual(const DialDeviceData& first, const DialDeviceData& second) { | 14 void ExpectEqual(const DialDeviceData& first, const DialDeviceData& second) { |
| 17 EXPECT_EQ(first.device_id(), second.device_id()); | 15 EXPECT_EQ(first.device_id(), second.device_id()); |
| 18 EXPECT_EQ(first.label(), second.label()); | 16 EXPECT_EQ(first.label(), second.label()); |
| 19 EXPECT_EQ(first.device_description_url(), second.device_description_url()); | 17 EXPECT_EQ(first.device_description_url(), second.device_description_url()); |
| 20 EXPECT_EQ(first.response_time(), second.response_time()); | 18 EXPECT_EQ(first.response_time(), second.response_time()); |
| 21 EXPECT_EQ(first.max_age(), second.max_age()); | 19 EXPECT_EQ(first.max_age(), second.max_age()); |
| 22 EXPECT_EQ(first.config_id(), second.config_id()); | 20 EXPECT_EQ(first.config_id(), second.config_id()); |
| 23 } | 21 } |
| 24 | 22 |
| 25 } // namespace | 23 } // namespace |
| 26 | 24 |
| 27 TEST(DialDeviceDataTest, TestFillDialDevice) { | |
| 28 api::dial::DialDevice api_device; | |
| 29 | |
| 30 DialDeviceData device; | |
| 31 device.set_device_id("device"); | |
| 32 device.set_label("label"); | |
| 33 device.set_device_description_url(GURL("http://127.0.0.1/dd.xml")); | |
| 34 device.set_config_id(1); | |
| 35 | |
| 36 device.FillDialDevice(&api_device); | |
| 37 EXPECT_EQ(api_device.device_label, device.label()); | |
| 38 EXPECT_EQ(api_device.device_description_url, | |
| 39 device.device_description_url().spec()); | |
| 40 EXPECT_EQ(*(api_device.config_id), device.config_id()); | |
| 41 } | |
| 42 | |
| 43 TEST(DialDeviceDataTest, TestUpdateFrom) { | 25 TEST(DialDeviceDataTest, TestUpdateFrom) { |
| 44 DialDeviceData original; | 26 DialDeviceData original; |
| 45 original.set_device_id("device_a"); | 27 original.set_device_id("device_a"); |
| 46 original.set_label("label_a"); | 28 original.set_label("label_a"); |
| 47 original.set_device_description_url(GURL("http://127.0.0.1/dd-a.xml")); | 29 original.set_device_description_url(GURL("http://127.0.0.1/dd-a.xml")); |
| 48 original.set_response_time(base::Time::FromInternalValue(1000)); | 30 original.set_response_time(base::Time::FromInternalValue(1000)); |
| 49 original.set_max_age(100); | 31 original.set_max_age(100); |
| 50 original.set_config_id(1); | 32 original.set_config_id(1); |
| 51 | 33 |
| 52 DialDeviceData new_data; | 34 DialDeviceData new_data; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 GURL("http://192.168.1.1:1234/dd.xml"))); | 78 GURL("http://192.168.1.1:1234/dd.xml"))); |
| 97 EXPECT_TRUE(DialDeviceData::IsDeviceDescriptionUrl( | 79 EXPECT_TRUE(DialDeviceData::IsDeviceDescriptionUrl( |
| 98 GURL("https://192.168.1.1:1234/dd.xml"))); | 80 GURL("https://192.168.1.1:1234/dd.xml"))); |
| 99 | 81 |
| 100 EXPECT_FALSE(DialDeviceData::IsDeviceDescriptionUrl(GURL())); | 82 EXPECT_FALSE(DialDeviceData::IsDeviceDescriptionUrl(GURL())); |
| 101 EXPECT_FALSE(DialDeviceData::IsDeviceDescriptionUrl(GURL(std::string()))); | 83 EXPECT_FALSE(DialDeviceData::IsDeviceDescriptionUrl(GURL(std::string()))); |
| 102 EXPECT_FALSE( | 84 EXPECT_FALSE( |
| 103 DialDeviceData::IsDeviceDescriptionUrl(GURL("file://path/to/file"))); | 85 DialDeviceData::IsDeviceDescriptionUrl(GURL("file://path/to/file"))); |
| 104 } | 86 } |
| 105 | 87 |
| 106 } // namespace dial | 88 } // namespace media_router |
| 107 } // namespace api | |
| 108 } // namespace extensions | |
| OLD | NEW |