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

Side by Side Diff: ash/common/mus_property_mirror_ash_unittest.cc

Issue 2736573002: chromeos: Move files in //ash/common to //ash, part 2 (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « ash/common/multi_profile_uma.cc ('k') | ash/common/new_window_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ash/public/cpp/mus_property_mirror_ash.h"
6
7 #include <string>
8
9 #include "ash/common/test/ash_test.h"
10 #include "ash/common/wm_window.h"
11 #include "ash/public/cpp/window_properties.h"
12 #include "base/strings/string16.h"
13 #include "base/strings/utf_string_conversions.h"
14 #include "ui/aura/client/aura_constants.h"
15 #include "ui/aura/window.h"
16
17 namespace ash {
18
19 using MusPropertyMirrorAshTest = AshTest;
20
21 // Ensure the property mirror can copy primitive properties between windows.
22 TEST_F(MusPropertyMirrorAshTest, PrimitiveProperties) {
23 MusPropertyMirrorAsh mus_property_mirror_ash;
24 std::unique_ptr<WindowOwner> window_owner_1(CreateTestWindow());
25 std::unique_ptr<WindowOwner> window_owner_2(CreateTestWindow());
26 aura::Window* window_1 = window_owner_1->window()->aura_window();
27 aura::Window* window_2 = window_owner_2->window()->aura_window();
28
29 EXPECT_EQ(TYPE_UNDEFINED, window_1->GetProperty(kShelfItemTypeKey));
30 EXPECT_EQ(TYPE_UNDEFINED, window_2->GetProperty(kShelfItemTypeKey));
31 window_1->SetProperty(kShelfItemTypeKey, static_cast<int32_t>(TYPE_APP));
32 EXPECT_EQ(TYPE_APP, window_1->GetProperty(kShelfItemTypeKey));
33 mus_property_mirror_ash.MirrorPropertyFromWidgetWindowToRootWindow(
34 window_1, window_2, kShelfItemTypeKey);
35 EXPECT_EQ(TYPE_APP, window_2->GetProperty(kShelfItemTypeKey));
36
37 EXPECT_FALSE(window_1->GetProperty(aura::client::kDrawAttentionKey));
38 EXPECT_FALSE(window_2->GetProperty(aura::client::kDrawAttentionKey));
39 window_1->SetProperty(aura::client::kDrawAttentionKey, true);
40 EXPECT_TRUE(window_1->GetProperty(aura::client::kDrawAttentionKey));
41 mus_property_mirror_ash.MirrorPropertyFromWidgetWindowToRootWindow(
42 window_1, window_2, aura::client::kDrawAttentionKey);
43 EXPECT_TRUE(window_2->GetProperty(aura::client::kDrawAttentionKey));
44 }
45
46 // Ensure the property mirror can copy owned object properties between windows.
47 TEST_F(MusPropertyMirrorAshTest, OwnedProperties) {
48 MusPropertyMirrorAsh mus_property_mirror_ash;
49 std::unique_ptr<WindowOwner> window_owner_1(CreateTestWindow());
50 std::unique_ptr<WindowOwner> window_owner_2(CreateTestWindow());
51 aura::Window* window_1 = window_owner_1->window()->aura_window();
52 aura::Window* window_2 = window_owner_2->window()->aura_window();
53
54 EXPECT_EQ(nullptr, window_1->GetProperty(aura::client::kAppIdKey));
55 EXPECT_EQ(nullptr, window_2->GetProperty(aura::client::kAppIdKey));
56 window_1->SetProperty(aura::client::kAppIdKey, new std::string("abc"));
57 EXPECT_EQ("abc", *window_1->GetProperty(aura::client::kAppIdKey));
58 mus_property_mirror_ash.MirrorPropertyFromWidgetWindowToRootWindow(
59 window_1, window_2, aura::client::kAppIdKey);
60 EXPECT_EQ("abc", *window_2->GetProperty(aura::client::kAppIdKey));
61 EXPECT_NE(window_1->GetProperty(aura::client::kAppIdKey),
62 window_2->GetProperty(aura::client::kAppIdKey));
63
64 EXPECT_EQ(nullptr, window_1->GetProperty(aura::client::kTitleKey));
65 EXPECT_EQ(nullptr, window_2->GetProperty(aura::client::kTitleKey));
66 window_1->SetProperty(aura::client::kTitleKey,
67 new base::string16(base::ASCIIToUTF16("def")));
68 EXPECT_EQ(base::ASCIIToUTF16("def"),
69 *window_1->GetProperty(aura::client::kTitleKey));
70 mus_property_mirror_ash.MirrorPropertyFromWidgetWindowToRootWindow(
71 window_1, window_2, aura::client::kTitleKey);
72 EXPECT_EQ(base::ASCIIToUTF16("def"),
73 *window_2->GetProperty(aura::client::kTitleKey));
74 EXPECT_NE(window_1->GetProperty(aura::client::kTitleKey),
75 window_2->GetProperty(aura::client::kTitleKey));
76
77 window_1->ClearProperty(aura::client::kWindowIconKey);
78 EXPECT_EQ(nullptr, window_1->GetProperty(aura::client::kWindowIconKey));
79 window_2->ClearProperty(aura::client::kWindowIconKey);
80 EXPECT_EQ(nullptr, window_2->GetProperty(aura::client::kWindowIconKey));
81 window_1->SetProperty(aura::client::kWindowIconKey, new gfx::ImageSkia());
82 EXPECT_NE(nullptr, window_1->GetProperty(aura::client::kWindowIconKey));
83 mus_property_mirror_ash.MirrorPropertyFromWidgetWindowToRootWindow(
84 window_1, window_2, aura::client::kWindowIconKey);
85 EXPECT_NE(nullptr, window_2->GetProperty(aura::client::kWindowIconKey));
86 EXPECT_NE(window_1->GetProperty(aura::client::kWindowIconKey),
87 window_2->GetProperty(aura::client::kWindowIconKey));
88 }
89
90 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/multi_profile_uma.cc ('k') | ash/common/new_window_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698