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

Side by Side Diff: ui/wm/core/window_util_unittest.cc

Issue 2854543002: Block incognito browser windows for voice interaction. (Closed)
Patch Set: WIP: Block incognito browser windows for voice interaction. Created 3 years, 7 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 | « ui/wm/core/window_util.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/wm/core/window_util.h" 5 #include "ui/wm/core/window_util.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h"
9 #include "ui/aura/test/aura_test_base.h" 10 #include "ui/aura/test/aura_test_base.h"
10 #include "ui/aura/test/test_windows.h" 11 #include "ui/aura/test/test_windows.h"
11 #include "ui/aura/window.h" 12 #include "ui/aura/window.h"
12 #include "ui/compositor/layer.h" 13 #include "ui/compositor/layer.h"
13 #include "ui/compositor/layer_tree_owner.h" 14 #include "ui/compositor/layer_tree_owner.h"
14 15
15 namespace wm { 16 namespace wm {
16 17
17 typedef aura::test::AuraTestBase WindowUtilTest; 18 typedef aura::test::AuraTestBase WindowUtilTest;
18 19
(...skipping 24 matching lines...) Expand all
43 44
44 // The original window should have both. 45 // The original window should have both.
45 ASSERT_EQ(2u, window1->layer()->children().size()); 46 ASSERT_EQ(2u, window1->layer()->children().size());
46 EXPECT_EQ(window11->layer(), window1->layer()->children()[0]); 47 EXPECT_EQ(window11->layer(), window1->layer()->children()[0]);
47 EXPECT_EQ(window12->layer(), window1->layer()->children()[1]); 48 EXPECT_EQ(window12->layer(), window1->layer()->children()[1]);
48 49
49 // Delete the window before the acquired layer is deleted. 50 // Delete the window before the acquired layer is deleted.
50 window11.reset(); 51 window11.reset();
51 } 52 }
52 53
54 // Test if map_func is correctly executed in RecreateLayerWithClosure.
55 TEST_F(WindowUtilTest, RecreateLayersWithClosure) {
56 std::unique_ptr<aura::Window> window1(
57 aura::test::CreateTestWindowWithId(0, NULL));
58 std::unique_ptr<aura::Window> window11(
59 aura::test::CreateTestWindowWithId(1, window1.get()));
60 std::unique_ptr<aura::Window> window12(
61 aura::test::CreateTestWindowWithId(2, window1.get()));
62
63 ASSERT_EQ(2u, window1->layer()->children().size());
64
65 auto tree_empty = wm::RecreateLayersWithClosure(
66 window1.get(),
67 base::BindRepeating(
68 [](const aura::Window* to_filter,
69 ui::LayerOwner* owner) -> std::unique_ptr<ui::Layer> {
70 if (owner->layer() == to_filter->layer())
71 return nullptr;
72 return owner->RecreateLayer();
73 },
74 window1.get()));
75
76 // The root is filtered. RecreateLayersWithClosure should return nullptr.
77 ASSERT_TRUE(!tree_empty);
sky 2017/05/18 02:50:15 The not makes this slightly hard to parse, use ASS
Muyuan 2017/05/18 02:58:24 Done.
78
79 auto tree = wm::RecreateLayersWithClosure(
80 window1.get(),
81 base::BindRepeating(
82 [](const aura::Window* to_filter,
83 ui::LayerOwner* owner) -> std::unique_ptr<ui::Layer> {
84 if (owner->layer() == to_filter->layer())
85 return nullptr;
86 return owner->RecreateLayer();
87 },
88 window12.get()));
89
90 // window12 is filtered out in the above recreation logic.
sky 2017/05/18 02:50:15 ASSERT_TRUE(tree) ?
Muyuan 2017/05/18 02:58:24 Done.
91 ASSERT_EQ(1u, tree->root()->children().size());
92 // Child layer is new instance.
93 EXPECT_NE(window11->layer(), tree->root()->children()[0]);
94
95 // The original window should have both.
96 ASSERT_EQ(2u, window1->layer()->children().size());
97 EXPECT_EQ(window11->layer(), window1->layer()->children()[0]);
98 EXPECT_EQ(window12->layer(), window1->layer()->children()[1]);
99 }
100
53 } // namespace wm 101 } // namespace wm
OLDNEW
« no previous file with comments | « ui/wm/core/window_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698