Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: ui/aura/mus/property_converter_unittest.cc

Issue 2632543003: Refactor and push window properties up to class properties. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ui/aura/mus/property_converter.h" 5 #include "ui/aura/mus/property_converter.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <string> 8 #include <string>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "services/ui/public/cpp/property_type_converters.h" 13 #include "services/ui/public/cpp/property_type_converters.h"
14 #include "third_party/skia/include/core/SkBitmap.h" 14 #include "third_party/skia/include/core/SkBitmap.h"
15 #include "ui/aura/client/aura_constants.h" 15 #include "ui/aura/client/aura_constants.h"
16 #include "ui/aura/test/aura_test_base.h" 16 #include "ui/aura/test/aura_test_base.h"
17 #include "ui/aura/window.h" 17 #include "ui/aura/window.h"
18 #include "ui/aura/window_property.h" 18 #include "ui/base/class_property.h"
19 #include "ui/gfx/geometry/rect.h" 19 #include "ui/gfx/geometry/rect.h"
20 #include "ui/gfx/image/image_skia.h" 20 #include "ui/gfx/image/image_skia.h"
21 #include "ui/gfx/skia_util.h" 21 #include "ui/gfx/skia_util.h"
22 22
23 // See aura_constants.cc for bool, int32_t, int64_t, std::string, gfx::Rect, 23 // See aura_constants.cc for bool, int32_t, int64_t, std::string, gfx::Rect,
24 // base::string16, uint32_t (via SkColor), and gfx::ImageSkia. 24 // base::string16, uint32_t (via SkColor), and gfx::ImageSkia.
25 DECLARE_WINDOW_PROPERTY_TYPE(uint8_t) 25 DECLARE_CLASS_PROPERTY_TYPE(uint8_t)
26 DECLARE_WINDOW_PROPERTY_TYPE(uint16_t) 26 DECLARE_CLASS_PROPERTY_TYPE(uint16_t)
27 DECLARE_WINDOW_PROPERTY_TYPE(uint64_t) 27 DECLARE_CLASS_PROPERTY_TYPE(uint64_t)
28 DECLARE_WINDOW_PROPERTY_TYPE(int8_t) 28 DECLARE_CLASS_PROPERTY_TYPE(int8_t)
29 DECLARE_WINDOW_PROPERTY_TYPE(int16_t) 29 DECLARE_CLASS_PROPERTY_TYPE(int16_t)
30 30
31 namespace aura { 31 namespace aura {
32 32
33 namespace { 33 namespace {
34 34
35 DEFINE_WINDOW_PROPERTY_KEY(bool, kTestPropertyKey0, false); 35 DEFINE_CLASS_PROPERTY_KEY(bool, kTestPropertyKey0, false);
36 DEFINE_WINDOW_PROPERTY_KEY(uint8_t, kTestPropertyKey1, 0); 36 DEFINE_CLASS_PROPERTY_KEY(uint8_t, kTestPropertyKey1, 0);
37 DEFINE_WINDOW_PROPERTY_KEY(uint16_t, kTestPropertyKey2, 0); 37 DEFINE_CLASS_PROPERTY_KEY(uint16_t, kTestPropertyKey2, 0);
38 DEFINE_WINDOW_PROPERTY_KEY(uint32_t, kTestPropertyKey3, 0); 38 DEFINE_CLASS_PROPERTY_KEY(uint32_t, kTestPropertyKey3, 0);
39 DEFINE_WINDOW_PROPERTY_KEY(uint64_t, kTestPropertyKey4, 0); 39 DEFINE_CLASS_PROPERTY_KEY(uint64_t, kTestPropertyKey4, 0);
40 DEFINE_WINDOW_PROPERTY_KEY(int8_t, kTestPropertyKey5, 0); 40 DEFINE_CLASS_PROPERTY_KEY(int8_t, kTestPropertyKey5, 0);
41 DEFINE_WINDOW_PROPERTY_KEY(int16_t, kTestPropertyKey6, 0); 41 DEFINE_CLASS_PROPERTY_KEY(int16_t, kTestPropertyKey6, 0);
42 DEFINE_WINDOW_PROPERTY_KEY(int32_t, kTestPropertyKey7, 0); 42 DEFINE_CLASS_PROPERTY_KEY(int32_t, kTestPropertyKey7, 0);
43 DEFINE_WINDOW_PROPERTY_KEY(int64_t, kTestPropertyKey8, 0); 43 DEFINE_CLASS_PROPERTY_KEY(int64_t, kTestPropertyKey8, 0);
44 44
45 DEFINE_OWNED_WINDOW_PROPERTY_KEY(gfx::ImageSkia, kTestImagePropertyKey, 45 DEFINE_OWNED_CLASS_PROPERTY_KEY(gfx::ImageSkia, kTestImagePropertyKey,
46 nullptr); 46 nullptr);
47 DEFINE_OWNED_WINDOW_PROPERTY_KEY(gfx::Rect, kTestRectPropertyKey, nullptr); 47 DEFINE_OWNED_CLASS_PROPERTY_KEY(gfx::Rect, kTestRectPropertyKey, nullptr);
48 DEFINE_OWNED_WINDOW_PROPERTY_KEY(gfx::Size, kTestSizePropertyKey, nullptr); 48 DEFINE_OWNED_CLASS_PROPERTY_KEY(gfx::Size, kTestSizePropertyKey, nullptr);
49 DEFINE_OWNED_WINDOW_PROPERTY_KEY(std::string, kTestStringPropertyKey, nullptr); 49 DEFINE_OWNED_CLASS_PROPERTY_KEY(std::string, kTestStringPropertyKey, nullptr);
50 DEFINE_OWNED_WINDOW_PROPERTY_KEY(base::string16, kTestString16PropertyKey, 50 DEFINE_OWNED_CLASS_PROPERTY_KEY(base::string16, kTestString16PropertyKey,
51 nullptr); 51 nullptr);
52 52
53 const char kTestPropertyServerKey0[] = "test-property-server0"; 53 const char kTestPropertyServerKey0[] = "test-property-server0";
54 const char kTestPropertyServerKey1[] = "test-property-server1"; 54 const char kTestPropertyServerKey1[] = "test-property-server1";
55 const char kTestPropertyServerKey2[] = "test-property-server2"; 55 const char kTestPropertyServerKey2[] = "test-property-server2";
56 const char kTestPropertyServerKey3[] = "test-property-server3"; 56 const char kTestPropertyServerKey3[] = "test-property-server3";
57 const char kTestPropertyServerKey4[] = "test-property-server4"; 57 const char kTestPropertyServerKey4[] = "test-property-server4";
58 const char kTestPropertyServerKey5[] = "test-property-server5"; 58 const char kTestPropertyServerKey5[] = "test-property-server5";
59 const char kTestPropertyServerKey6[] = "test-property-server6"; 59 const char kTestPropertyServerKey6[] = "test-property-server6";
60 const char kTestPropertyServerKey7[] = "test-property-server7"; 60 const char kTestPropertyServerKey7[] = "test-property-server7";
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 312
313 base::string16 value_2 = base::ASCIIToUTF16("another test value"); 313 base::string16 value_2 = base::ASCIIToUTF16("another test value");
314 std::vector<uint8_t> transport_value = 314 std::vector<uint8_t> transport_value =
315 mojo::ConvertTo<std::vector<uint8_t>>(value_2); 315 mojo::ConvertTo<std::vector<uint8_t>>(value_2);
316 property_converter.SetPropertyFromTransportValue( 316 property_converter.SetPropertyFromTransportValue(
317 window.get(), kTestString16PropertyServerKey, &transport_value); 317 window.get(), kTestString16PropertyServerKey, &transport_value);
318 EXPECT_EQ(value_2, *window->GetProperty(kTestString16PropertyKey)); 318 EXPECT_EQ(value_2, *window->GetProperty(kTestString16PropertyKey));
319 } 319 }
320 320
321 } // namespace aura 321 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698