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

Side by Side Diff: ui/views/mus/native_widget_mus_unittest.cc

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 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/views/mus/native_widget_mus.h ('k') | ui/views/mus/platform_test_helper_mus.cc » ('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 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/views/mus/native_widget_mus.h" 5 #include "ui/views/mus/native_widget_mus.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "components/mus/public/cpp/property_type_converters.h" 8 #include "components/mus/public/cpp/property_type_converters.h"
9 #include "components/mus/public/cpp/window.h" 9 #include "components/mus/public/cpp/window.h"
10 #include "components/mus/public/cpp/window_property.h" 10 #include "components/mus/public/cpp/window_property.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 ASSERT_EQ(2u, activation_observer.changes().size()); 129 ASSERT_EQ(2u, activation_observer.changes().size());
130 EXPECT_TRUE(activation_observer.changes()[1]); 130 EXPECT_TRUE(activation_observer.changes()[1]);
131 131
132 WidgetFocusManager::GetInstance()->RemoveFocusChangeListener(&focus_listener); 132 WidgetFocusManager::GetInstance()->RemoveFocusChangeListener(&focus_listener);
133 } 133 }
134 134
135 // Tests that a window with an icon sets the mus::Window icon property. 135 // Tests that a window with an icon sets the mus::Window icon property.
136 TEST_F(NativeWidgetMusTest, AppIcon) { 136 TEST_F(NativeWidgetMusTest, AppIcon) {
137 // Create a Widget with a bitmap as the icon. 137 // Create a Widget with a bitmap as the icon.
138 SkBitmap source_bitmap = MakeBitmap(SK_ColorRED); 138 SkBitmap source_bitmap = MakeBitmap(SK_ColorRED);
139 scoped_ptr<Widget> widget( 139 std::unique_ptr<Widget> widget(
140 CreateWidget(new TestWidgetDelegate(source_bitmap))); 140 CreateWidget(new TestWidgetDelegate(source_bitmap)));
141 141
142 // The mus::Window has the icon property. 142 // The mus::Window has the icon property.
143 mus::Window* window = 143 mus::Window* window =
144 static_cast<NativeWidgetMus*>(widget->native_widget_private())->window(); 144 static_cast<NativeWidgetMus*>(widget->native_widget_private())->window();
145 EXPECT_TRUE(window->HasSharedProperty( 145 EXPECT_TRUE(window->HasSharedProperty(
146 mus::mojom::WindowManager::kWindowAppIcon_Property)); 146 mus::mojom::WindowManager::kWindowAppIcon_Property));
147 147
148 // The icon is the expected icon. 148 // The icon is the expected icon.
149 SkBitmap icon = window->GetSharedProperty<SkBitmap>( 149 SkBitmap icon = window->GetSharedProperty<SkBitmap>(
150 mus::mojom::WindowManager::kWindowAppIcon_Property); 150 mus::mojom::WindowManager::kWindowAppIcon_Property);
151 EXPECT_TRUE(gfx::BitmapsAreEqual(source_bitmap, icon)); 151 EXPECT_TRUE(gfx::BitmapsAreEqual(source_bitmap, icon));
152 } 152 }
153 153
154 // Tests that a window without an icon does not set the mus::Window icon 154 // Tests that a window without an icon does not set the mus::Window icon
155 // property. 155 // property.
156 TEST_F(NativeWidgetMusTest, NoAppIcon) { 156 TEST_F(NativeWidgetMusTest, NoAppIcon) {
157 // Create a Widget without a special icon. 157 // Create a Widget without a special icon.
158 scoped_ptr<Widget> widget(CreateWidget(nullptr)); 158 std::unique_ptr<Widget> widget(CreateWidget(nullptr));
159 159
160 // The mus::Window does not have an icon property. 160 // The mus::Window does not have an icon property.
161 mus::Window* window = 161 mus::Window* window =
162 static_cast<NativeWidgetMus*>(widget->native_widget_private())->window(); 162 static_cast<NativeWidgetMus*>(widget->native_widget_private())->window();
163 EXPECT_FALSE(window->HasSharedProperty( 163 EXPECT_FALSE(window->HasSharedProperty(
164 mus::mojom::WindowManager::kWindowAppIcon_Property)); 164 mus::mojom::WindowManager::kWindowAppIcon_Property));
165 } 165 }
166 166
167 // Tests that changing the icon on a Widget updates the mus::Window icon 167 // Tests that changing the icon on a Widget updates the mus::Window icon
168 // property. 168 // property.
169 TEST_F(NativeWidgetMusTest, ChangeAppIcon) { 169 TEST_F(NativeWidgetMusTest, ChangeAppIcon) {
170 // Create a Widget with an icon. 170 // Create a Widget with an icon.
171 SkBitmap bitmap1 = MakeBitmap(SK_ColorRED); 171 SkBitmap bitmap1 = MakeBitmap(SK_ColorRED);
172 TestWidgetDelegate* delegate = new TestWidgetDelegate(bitmap1); 172 TestWidgetDelegate* delegate = new TestWidgetDelegate(bitmap1);
173 scoped_ptr<Widget> widget(CreateWidget(delegate)); 173 std::unique_ptr<Widget> widget(CreateWidget(delegate));
174 174
175 // Update the icon to a new image. 175 // Update the icon to a new image.
176 SkBitmap bitmap2 = MakeBitmap(SK_ColorGREEN); 176 SkBitmap bitmap2 = MakeBitmap(SK_ColorGREEN);
177 delegate->SetIcon(bitmap2); 177 delegate->SetIcon(bitmap2);
178 widget->UpdateWindowIcon(); 178 widget->UpdateWindowIcon();
179 179
180 // The window has the updated icon. 180 // The window has the updated icon.
181 mus::Window* window = 181 mus::Window* window =
182 static_cast<NativeWidgetMus*>(widget->native_widget_private())->window(); 182 static_cast<NativeWidgetMus*>(widget->native_widget_private())->window();
183 SkBitmap icon = window->GetSharedProperty<SkBitmap>( 183 SkBitmap icon = window->GetSharedProperty<SkBitmap>(
184 mus::mojom::WindowManager::kWindowAppIcon_Property); 184 mus::mojom::WindowManager::kWindowAppIcon_Property);
185 EXPECT_TRUE(gfx::BitmapsAreEqual(bitmap2, icon)); 185 EXPECT_TRUE(gfx::BitmapsAreEqual(bitmap2, icon));
186 } 186 }
187 187
188 TEST_F(NativeWidgetMusTest, ValidLayerTree) { 188 TEST_F(NativeWidgetMusTest, ValidLayerTree) {
189 scoped_ptr<Widget> widget(CreateWidget(nullptr)); 189 std::unique_ptr<Widget> widget(CreateWidget(nullptr));
190 View* content = new View; 190 View* content = new View;
191 content->SetPaintToLayer(true); 191 content->SetPaintToLayer(true);
192 widget->GetContentsView()->AddChildView(content); 192 widget->GetContentsView()->AddChildView(content);
193 EXPECT_TRUE(widget->GetNativeWindow()->layer()->Contains(content->layer())); 193 EXPECT_TRUE(widget->GetNativeWindow()->layer()->Contains(content->layer()));
194 } 194 }
195 195
196 } // namespace 196 } // namespace
197 } // namespace views 197 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/native_widget_mus.h ('k') | ui/views/mus/platform_test_helper_mus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698