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

Side by Side Diff: ash/shelf/shelf_layout_manager_unittest.cc

Issue 1867223004: Convert //ash from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/shelf/shelf_layout_manager.h" 5 #include "ash/shelf/shelf_layout_manager.h"
6 6
7 #include "ash/accelerators/accelerator_controller.h" 7 #include "ash/accelerators/accelerator_controller.h"
8 #include "ash/accelerators/accelerator_table.h" 8 #include "ash/accelerators/accelerator_table.h"
9 #include "ash/ash_switches.h" 9 #include "ash/ash_switches.h"
10 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
(...skipping 2096 matching lines...) Expand 10 before | Expand all | Expand 10 after
2107 EXPECT_EQ(widget_one->GetNativeWindow()->bounds().ToString(), 2107 EXPECT_EQ(widget_one->GetNativeWindow()->bounds().ToString(),
2108 widget_two->GetNativeWindow()->bounds().ToString()); 2108 widget_two->GetNativeWindow()->bounds().ToString());
2109 EXPECT_EQ(area_when_shelf_shown, 2109 EXPECT_EQ(area_when_shelf_shown,
2110 widget_one->GetNativeWindow()->bounds().size().GetArea()); 2110 widget_one->GetNativeWindow()->bounds().size().GetArea());
2111 } 2111 }
2112 2112
2113 // Confirm that the shelf is dimmed only when content is maximized and 2113 // Confirm that the shelf is dimmed only when content is maximized and
2114 // shelf is not autohidden. 2114 // shelf is not autohidden.
2115 TEST_F(ShelfLayoutManagerTest, Dimming) { 2115 TEST_F(ShelfLayoutManagerTest, Dimming) {
2116 GetShelfLayoutManager()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 2116 GetShelfLayoutManager()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
2117 scoped_ptr<aura::Window> w1(CreateTestWindow()); 2117 std::unique_ptr<aura::Window> w1(CreateTestWindow());
2118 w1->Show(); 2118 w1->Show();
2119 wm::ActivateWindow(w1.get()); 2119 wm::ActivateWindow(w1.get());
2120 2120
2121 // Normal window doesn't dim shelf. 2121 // Normal window doesn't dim shelf.
2122 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 2122 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
2123 ShelfWidget* shelf = GetShelfWidget(); 2123 ShelfWidget* shelf = GetShelfWidget();
2124 EXPECT_FALSE(shelf->GetDimsShelf()); 2124 EXPECT_FALSE(shelf->GetDimsShelf());
2125 2125
2126 // Maximized window does. 2126 // Maximized window does.
2127 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 2127 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2188 } else { 2188 } else {
2189 EXPECT_FALSE(shelf->IsVisible()); 2189 EXPECT_FALSE(shelf->IsVisible());
2190 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); 2190 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown());
2191 } 2191 }
2192 } 2192 }
2193 } 2193 }
2194 2194
2195 TEST_F(ShelfLayoutManagerTest, ShelfBackgroundColor) { 2195 TEST_F(ShelfLayoutManagerTest, ShelfBackgroundColor) {
2196 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, GetShelfWidget()->GetBackgroundType()); 2196 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, GetShelfWidget()->GetBackgroundType());
2197 2197
2198 scoped_ptr<aura::Window> w1(CreateTestWindow()); 2198 std::unique_ptr<aura::Window> w1(CreateTestWindow());
2199 w1->Show(); 2199 w1->Show();
2200 wm::ActivateWindow(w1.get()); 2200 wm::ActivateWindow(w1.get());
2201 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, GetShelfWidget()->GetBackgroundType()); 2201 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, GetShelfWidget()->GetBackgroundType());
2202 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 2202 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
2203 EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, GetShelfWidget()->GetBackgroundType()); 2203 EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, GetShelfWidget()->GetBackgroundType());
2204 2204
2205 scoped_ptr<aura::Window> w2(CreateTestWindow()); 2205 std::unique_ptr<aura::Window> w2(CreateTestWindow());
2206 w2->Show(); 2206 w2->Show();
2207 wm::ActivateWindow(w2.get()); 2207 wm::ActivateWindow(w2.get());
2208 // Overlaps with shelf. 2208 // Overlaps with shelf.
2209 w2->SetBounds(GetShelfLayoutManager()->GetIdealBounds()); 2209 w2->SetBounds(GetShelfLayoutManager()->GetIdealBounds());
2210 2210
2211 // Still background is 'maximized'. 2211 // Still background is 'maximized'.
2212 EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, GetShelfWidget()->GetBackgroundType()); 2212 EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, GetShelfWidget()->GetBackgroundType());
2213 2213
2214 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); 2214 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
2215 EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, GetShelfWidget()->GetBackgroundType()); 2215 EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, GetShelfWidget()->GetBackgroundType());
2216 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); 2216 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
2217 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, GetShelfWidget()->GetBackgroundType()); 2217 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, GetShelfWidget()->GetBackgroundType());
2218 2218
2219 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 2219 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
2220 EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, GetShelfWidget()->GetBackgroundType()); 2220 EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, GetShelfWidget()->GetBackgroundType());
2221 w1.reset(); 2221 w1.reset();
2222 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, GetShelfWidget()->GetBackgroundType()); 2222 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, GetShelfWidget()->GetBackgroundType());
2223 } 2223 }
2224 2224
2225 // Verify that the shelf doesn't have the opaque background if it's auto-hide 2225 // Verify that the shelf doesn't have the opaque background if it's auto-hide
2226 // status. 2226 // status.
2227 TEST_F(ShelfLayoutManagerTest, ShelfBackgroundColorAutoHide) { 2227 TEST_F(ShelfLayoutManagerTest, ShelfBackgroundColorAutoHide) {
2228 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, GetShelfWidget ()->GetBackgroundType()); 2228 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, GetShelfWidget ()->GetBackgroundType());
2229 2229
2230 GetShelfLayoutManager()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 2230 GetShelfLayoutManager()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
2231 scoped_ptr<aura::Window> w1(CreateTestWindow()); 2231 std::unique_ptr<aura::Window> w1(CreateTestWindow());
2232 w1->Show(); 2232 w1->Show();
2233 wm::ActivateWindow(w1.get()); 2233 wm::ActivateWindow(w1.get());
2234 EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, GetShelfWidget()->GetBackgroundType()); 2234 EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, GetShelfWidget()->GetBackgroundType());
2235 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 2235 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
2236 EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, GetShelfWidget()->GetBackgroundType()); 2236 EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, GetShelfWidget()->GetBackgroundType());
2237 } 2237 }
2238 2238
2239 #if defined(OS_CHROMEOS) 2239 #if defined(OS_CHROMEOS)
2240 #define MAYBE_StatusAreaHitBoxCoversEdge StatusAreaHitBoxCoversEdge 2240 #define MAYBE_StatusAreaHitBoxCoversEdge StatusAreaHitBoxCoversEdge
2241 #else 2241 #else
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
2300 // handled, and do not crash (crbug.com/458768) 2300 // handled, and do not crash (crbug.com/458768)
2301 TEST_F(ShelfLayoutManagerTest, ShutdownHandlesWindowActivation) { 2301 TEST_F(ShelfLayoutManagerTest, ShutdownHandlesWindowActivation) {
2302 ShelfLayoutManager* shelf_manager = GetShelfLayoutManager(); 2302 ShelfLayoutManager* shelf_manager = GetShelfLayoutManager();
2303 ShelfWidget* shelf = GetShelfWidget(); 2303 ShelfWidget* shelf = GetShelfWidget();
2304 shelf_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 2304 shelf_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
2305 2305
2306 aura::Window* window1 = CreateTestWindowInShellWithId(0); 2306 aura::Window* window1 = CreateTestWindowInShellWithId(0);
2307 window1->SetBounds(gfx::Rect(0, 0, 100, 100)); 2307 window1->SetBounds(gfx::Rect(0, 0, 100, 100));
2308 window1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 2308 window1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
2309 window1->Show(); 2309 window1->Show();
2310 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(0)); 2310 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(0));
2311 window2->SetBounds(gfx::Rect(0, 0, 100, 100)); 2311 window2->SetBounds(gfx::Rect(0, 0, 100, 100));
2312 window2->Show(); 2312 window2->Show();
2313 wm::ActivateWindow(window1); 2313 wm::ActivateWindow(window1);
2314 2314
2315 shelf->ShutdownStatusAreaWidget(); 2315 shelf->ShutdownStatusAreaWidget();
2316 shelf_manager->PrepareForShutdown(); 2316 shelf_manager->PrepareForShutdown();
2317 2317
2318 // Deleting a focused maximized window will switch focus to |window2|. This 2318 // Deleting a focused maximized window will switch focus to |window2|. This
2319 // would normally cause the ShelfLayoutManager to update its state. However 2319 // would normally cause the ShelfLayoutManager to update its state. However
2320 // during shutdown we want to handle this without crashing. 2320 // during shutdown we want to handle this without crashing.
(...skipping 10 matching lines...) Expand all
2331 StatusAreaWidget* status_area_widget = 2331 StatusAreaWidget* status_area_widget =
2332 Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget(); 2332 Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget();
2333 EXPECT_TRUE(status_area_widget->IsVisible()); 2333 EXPECT_TRUE(status_area_widget->IsVisible());
2334 // Shelf should be in the first display's area. 2334 // Shelf should be in the first display's area.
2335 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen()); 2335 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen());
2336 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds)); 2336 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds));
2337 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right()); 2337 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right());
2338 } 2338 }
2339 2339
2340 } // namespace ash 2340 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698