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 #include "stdafx.h" | 4 #include "stdafx.h" |
5 | 5 |
6 #include "winrt_utils.h" | 6 #include "winrt_utils.h" |
7 | 7 |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 namespace { | 11 namespace { |
12 | 12 |
13 template <typename Type> | 13 template <typename Type> |
14 static HRESULT CreateProperty(Type value, winfoundtn::IPropertyValue** prop) { | 14 HRESULT CreateProperty(Type value, winfoundtn::IPropertyValue** prop) { |
15 return E_NOTIMPL; | 15 return E_NOTIMPL; |
16 } | 16 } |
17 | 17 |
18 template <> | 18 template <> |
19 static HRESULT CreateProperty<const wchar_t*>( | 19 HRESULT CreateProperty<const wchar_t*>( |
20 const wchar_t* value, winfoundtn::IPropertyValue** prop) { | 20 const wchar_t* value, winfoundtn::IPropertyValue** prop) { |
21 mswrw::HString string_value; | 21 mswrw::HString string_value; |
22 string_value.Attach(MakeHString(value)); | 22 string_value.Attach(MakeHString(value)); |
23 return winrt_utils::CreateStringProperty(string_value.Get(), prop); | 23 return winrt_utils::CreateStringProperty(string_value.Get(), prop); |
24 } | 24 } |
25 | 25 |
26 template <> | 26 template <> |
27 static HRESULT CreateProperty<INT16>(INT16 value, | 27 HRESULT CreateProperty<INT16>(INT16 value, |
28 winfoundtn::IPropertyValue** prop) { | 28 winfoundtn::IPropertyValue** prop) { |
29 return winrt_utils::CreateInt16Property(value, prop); | 29 return winrt_utils::CreateInt16Property(value, prop); |
30 } | 30 } |
31 | 31 |
32 template <> | 32 template <> |
33 static HRESULT CreateProperty<INT32>(INT32 value, | 33 HRESULT CreateProperty<INT32>(INT32 value, |
34 winfoundtn::IPropertyValue** prop) { | 34 winfoundtn::IPropertyValue** prop) { |
35 return winrt_utils::CreateInt32Property(value, prop); | 35 return winrt_utils::CreateInt32Property(value, prop); |
36 } | 36 } |
37 | 37 |
38 template <> | 38 template <> |
39 static HRESULT CreateProperty<INT64>(INT64 value, | 39 HRESULT CreateProperty<INT64>(INT64 value, |
40 winfoundtn::IPropertyValue** prop) { | 40 winfoundtn::IPropertyValue** prop) { |
41 return winrt_utils::CreateInt64Property(value, prop); | 41 return winrt_utils::CreateInt64Property(value, prop); |
42 } | 42 } |
43 | 43 |
44 template <> | 44 template <> |
45 static HRESULT CreateProperty<UINT8>(UINT8 value, | 45 HRESULT CreateProperty<UINT8>(UINT8 value, |
46 winfoundtn::IPropertyValue** prop) { | 46 winfoundtn::IPropertyValue** prop) { |
47 return winrt_utils::CreateUInt8Property(value, prop); | 47 return winrt_utils::CreateUInt8Property(value, prop); |
48 } | 48 } |
49 | 49 |
50 template <> | 50 template <> |
51 static HRESULT CreateProperty<UINT16>(UINT16 value, | 51 HRESULT CreateProperty<UINT16>(UINT16 value, |
52 winfoundtn::IPropertyValue** prop) { | 52 winfoundtn::IPropertyValue** prop) { |
53 return winrt_utils::CreateUInt16Property(value, prop); | 53 return winrt_utils::CreateUInt16Property(value, prop); |
54 } | 54 } |
55 | 55 |
56 template <> | 56 template <> |
57 static HRESULT CreateProperty<UINT32>(UINT32 value, | 57 HRESULT CreateProperty<UINT32>(UINT32 value, |
58 winfoundtn::IPropertyValue** prop) { | 58 winfoundtn::IPropertyValue** prop) { |
59 return winrt_utils::CreateUInt32Property(value, prop); | 59 return winrt_utils::CreateUInt32Property(value, prop); |
60 } | 60 } |
61 | 61 |
62 template <> | 62 template <> |
63 static HRESULT CreateProperty<UINT64>(UINT64 value, | 63 HRESULT CreateProperty<UINT64>(UINT64 value, |
64 winfoundtn::IPropertyValue** prop) { | 64 winfoundtn::IPropertyValue** prop) { |
65 return winrt_utils::CreateUInt64Property(value, prop); | 65 return winrt_utils::CreateUInt64Property(value, prop); |
66 } | 66 } |
67 | 67 |
68 template<typename Type> | 68 template<typename Type> |
69 void TestCompareProperties(Type value1, Type value2) { | 69 void TestCompareProperties(Type value1, Type value2) { |
70 mswr::ComPtr<winfoundtn::IPropertyValue> property_1; | 70 mswr::ComPtr<winfoundtn::IPropertyValue> property_1; |
71 HRESULT hr = CreateProperty<Type>(value1, property_1.GetAddressOf()); | 71 HRESULT hr = CreateProperty<Type>(value1, property_1.GetAddressOf()); |
72 ASSERT_TRUE(SUCCEEDED(hr)) << "Can't create Property value 1"; | 72 ASSERT_TRUE(SUCCEEDED(hr)) << "Can't create Property value 1"; |
73 | 73 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 TestCompareProperties<INT32>(42, 43); | 106 TestCompareProperties<INT32>(42, 43); |
107 TestCompareProperties<INT64>(42, 43); | 107 TestCompareProperties<INT64>(42, 43); |
108 TestCompareProperties<UINT8>(42, 43); | 108 TestCompareProperties<UINT8>(42, 43); |
109 TestCompareProperties<UINT16>(42, 43); | 109 TestCompareProperties<UINT16>(42, 43); |
110 TestCompareProperties<UINT32>(42, 43); | 110 TestCompareProperties<UINT32>(42, 43); |
111 TestCompareProperties<UINT64>(42, 43); | 111 TestCompareProperties<UINT64>(42, 43); |
112 TestCompareProperties<const wchar_t*>(L"abc", L"bcd"); | 112 TestCompareProperties<const wchar_t*>(L"abc", L"bcd"); |
113 } | 113 } |
114 | 114 |
115 } // namespace | 115 } // namespace |
OLD | NEW |