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

Side by Side Diff: components/exo/display_unittest.cc

Issue 1419373013: exo: Add support for subcompositor interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@exosphere-xdg-shell
Patch Set: address review feedback Created 5 years, 1 month 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 | « components/exo/display.cc ('k') | components/exo/shell_surface.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/exo/buffer.h" 5 #include "components/exo/buffer.h"
6 #include "components/exo/display.h" 6 #include "components/exo/display.h"
7 #include "components/exo/shared_memory.h" 7 #include "components/exo/shared_memory.h"
8 #include "components/exo/shell_surface.h" 8 #include "components/exo/shell_surface.h"
9 #include "components/exo/sub_surface.h"
9 #include "components/exo/surface.h" 10 #include "components/exo/surface.h"
10 #include "components/exo/test/exo_test_base.h" 11 #include "components/exo/test/exo_test_base.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 namespace exo { 14 namespace exo {
14 namespace { 15 namespace {
15 16
16 using DisplayTest = test::ExoTestBase; 17 using DisplayTest = test::ExoTestBase;
17 18
18 TEST_F(DisplayTest, CreateSurface) { 19 TEST_F(DisplayTest, CreateSurface) {
(...skipping 24 matching lines...) Expand all
43 scoped_ptr<SharedMemory> shm2 = 44 scoped_ptr<SharedMemory> shm2 =
44 display->CreateSharedMemory(base::SharedMemoryHandle(), shm_size); 45 display->CreateSharedMemory(base::SharedMemoryHandle(), shm_size);
45 EXPECT_FALSE(shm2); 46 EXPECT_FALSE(shm2);
46 } 47 }
47 48
48 TEST_F(DisplayTest, CreateShellSurface) { 49 TEST_F(DisplayTest, CreateShellSurface) {
49 scoped_ptr<Display> display(new Display); 50 scoped_ptr<Display> display(new Display);
50 51
51 // Create two surfaces. 52 // Create two surfaces.
52 scoped_ptr<Surface> surface1 = display->CreateSurface(); 53 scoped_ptr<Surface> surface1 = display->CreateSurface();
53 EXPECT_TRUE(surface1); 54 ASSERT_TRUE(surface1);
54 scoped_ptr<Surface> surface2 = display->CreateSurface(); 55 scoped_ptr<Surface> surface2 = display->CreateSurface();
55 EXPECT_TRUE(surface2); 56 ASSERT_TRUE(surface2);
56 57
57 // Create a shell surface for surface1. 58 // Create a shell surface for surface1.
58 scoped_ptr<ShellSurface> shell_surface1 = 59 scoped_ptr<ShellSurface> shell_surface1 =
59 display->CreateShellSurface(surface1.get()); 60 display->CreateShellSurface(surface1.get());
61 EXPECT_TRUE(shell_surface1);
60 62
61 // Create a shell surface for surface2. 63 // Create a shell surface for surface2.
62 scoped_ptr<ShellSurface> shell_surface2 = 64 scoped_ptr<ShellSurface> shell_surface2 =
63 display->CreateShellSurface(surface2.get()); 65 display->CreateShellSurface(surface2.get());
66 EXPECT_TRUE(shell_surface2);
67 }
68
69 TEST_F(DisplayTest, CreateSubSurface) {
70 scoped_ptr<Display> display(new Display);
71
72 // Create child, parent and toplevel surfaces.
73 scoped_ptr<Surface> child = display->CreateSurface();
74 ASSERT_TRUE(child);
75 scoped_ptr<Surface> parent = display->CreateSurface();
76 ASSERT_TRUE(parent);
77 scoped_ptr<Surface> toplevel = display->CreateSurface();
78 ASSERT_TRUE(toplevel);
79
80 // Attempting to create a sub surface for child with child as its parent
81 // should fail.
82 EXPECT_FALSE(display->CreateSubSurface(child.get(), child.get()));
83
84 // Create a sub surface for child.
85 scoped_ptr<SubSurface> child_sub_surface =
86 display->CreateSubSurface(child.get(), toplevel.get());
87 EXPECT_TRUE(child_sub_surface);
88
89 // Attempting to create another sub surface when already assigned the role of
90 // sub surface should fail.
91 EXPECT_FALSE(display->CreateSubSurface(child.get(), parent.get()));
92
93 // Deleting the sub surface should allow a new sub surface to be created.
94 child_sub_surface.reset();
95 child_sub_surface = display->CreateSubSurface(child.get(), parent.get());
96 EXPECT_TRUE(child_sub_surface);
97
98 scoped_ptr<Surface> sibling = display->CreateSurface();
99 ASSERT_TRUE(sibling);
100
101 // Create a sub surface for sibiling.
102 scoped_ptr<SubSurface> sibling_sub_surface =
103 display->CreateSubSurface(sibling.get(), parent.get());
104 EXPECT_TRUE(sibling_sub_surface);
105
106 // Create a shell surface for toplevel surface.
107 scoped_ptr<ShellSurface> shell_surface =
108 display->CreateShellSurface(toplevel.get());
109 EXPECT_TRUE(shell_surface);
110
111 // Attempting to create a sub surface when already assigned the role of
112 // shell surface should fail.
113 EXPECT_FALSE(display->CreateSubSurface(toplevel.get(), parent.get()));
114
115 scoped_ptr<Surface> grandchild = display->CreateSurface();
116 ASSERT_TRUE(grandchild);
117 // Create a sub surface for grandchild.
118 scoped_ptr<SubSurface> grandchild_sub_surface =
119 display->CreateSubSurface(grandchild.get(), child.get());
120 EXPECT_TRUE(grandchild_sub_surface);
121
122 // Attempting to create a sub surface for parent with child as its parent
123 // should fail.
124 EXPECT_FALSE(display->CreateSubSurface(parent.get(), child.get()));
125
126 // Attempting to create a sub surface for parent with grandchild as its parent
127 // should fail.
128 EXPECT_FALSE(display->CreateSubSurface(parent.get(), grandchild.get()));
129
130 // Create a sub surface for parent.
131 EXPECT_TRUE(display->CreateSubSurface(parent.get(), toplevel.get()));
64 } 132 }
65 133
66 } // namespace 134 } // namespace
67 } // namespace exo 135 } // namespace exo
OLDNEW
« no previous file with comments | « components/exo/display.cc ('k') | components/exo/shell_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698