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

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

Issue 1547223002: Convert Pass()→std::move() in //ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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/shelf/shelf_unittest.cc ('k') | ash/shelf/shelf_window_watcher.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 (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_view.h" 5 #include "ash/shelf/shelf_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 326
327 void TearDown() override { 327 void TearDown() override {
328 shelf_delegate_ = nullptr; 328 shelf_delegate_ = nullptr;
329 test_api_.reset(); 329 test_api_.reset();
330 AshTestBase::TearDown(); 330 AshTestBase::TearDown();
331 } 331 }
332 332
333 protected: 333 protected:
334 void CreateAndSetShelfItemDelegateForID(ShelfID id) { 334 void CreateAndSetShelfItemDelegateForID(ShelfID id) {
335 scoped_ptr<ShelfItemDelegate> delegate(new TestShelfItemDelegate(NULL)); 335 scoped_ptr<ShelfItemDelegate> delegate(new TestShelfItemDelegate(NULL));
336 item_manager_->SetShelfItemDelegate(id, delegate.Pass()); 336 item_manager_->SetShelfItemDelegate(id, std::move(delegate));
337 } 337 }
338 338
339 ShelfID AddBrowserShortcut() { 339 ShelfID AddBrowserShortcut() {
340 ShelfItem browser_shortcut; 340 ShelfItem browser_shortcut;
341 browser_shortcut.type = TYPE_BROWSER_SHORTCUT; 341 browser_shortcut.type = TYPE_BROWSER_SHORTCUT;
342 342
343 ShelfID id = model_->next_id(); 343 ShelfID id = model_->next_id();
344 model_->AddAt(browser_index_, browser_shortcut); 344 model_->AddAt(browser_index_, browser_shortcut);
345 CreateAndSetShelfItemDelegateForID(id); 345 CreateAndSetShelfItemDelegateForID(id);
346 test_api_->RunMessageLoopUntilAnimationsDone(); 346 test_api_->RunMessageLoopUntilAnimationsDone();
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 dragged_button, ShelfButtonHost::MOUSE, false); 1234 dragged_button, ShelfButtonHost::MOUSE, false);
1235 EXPECT_TRUE(model_->items()[3].type == TYPE_BROWSER_SHORTCUT); 1235 EXPECT_TRUE(model_->items()[3].type == TYPE_BROWSER_SHORTCUT);
1236 } 1236 }
1237 1237
1238 // Tests that double-clicking an item does not activate it twice. 1238 // Tests that double-clicking an item does not activate it twice.
1239 TEST_F(ShelfViewTest, ClickingTwiceActivatesOnce) { 1239 TEST_F(ShelfViewTest, ClickingTwiceActivatesOnce) {
1240 // Watch for selection of the browser shortcut. 1240 // Watch for selection of the browser shortcut.
1241 ShelfID browser_shelf_id = model_->items()[browser_index_].id; 1241 ShelfID browser_shelf_id = model_->items()[browser_index_].id;
1242 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker; 1242 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker;
1243 item_manager_->SetShelfItemDelegate( 1243 item_manager_->SetShelfItemDelegate(
1244 browser_shelf_id, 1244 browser_shelf_id, scoped_ptr<ShelfItemDelegate>(selection_tracker));
1245 scoped_ptr<ShelfItemDelegate>(selection_tracker).Pass());
1246 1245
1247 // A single click selects the item. 1246 // A single click selects the item.
1248 SimulateClick(browser_index_); 1247 SimulateClick(browser_index_);
1249 EXPECT_TRUE(selection_tracker->WasSelected()); 1248 EXPECT_TRUE(selection_tracker->WasSelected());
1250 1249
1251 // A double-click does not select the item. 1250 // A double-click does not select the item.
1252 selection_tracker->Reset(); 1251 selection_tracker->Reset();
1253 SimulateDoubleClick(browser_index_); 1252 SimulateDoubleClick(browser_index_);
1254 EXPECT_FALSE(selection_tracker->WasSelected()); 1253 EXPECT_FALSE(selection_tracker->WasSelected());
1255 } 1254 }
1256 1255
1257 // Check that clicking an item and jittering the mouse a bit still selects the 1256 // Check that clicking an item and jittering the mouse a bit still selects the
1258 // item. 1257 // item.
1259 TEST_F(ShelfViewTest, ClickAndMoveSlightly) { 1258 TEST_F(ShelfViewTest, ClickAndMoveSlightly) {
1260 std::vector<std::pair<ShelfID, views::View*> > id_map; 1259 std::vector<std::pair<ShelfID, views::View*> > id_map;
1261 SetupForDragTest(&id_map); 1260 SetupForDragTest(&id_map);
1262 1261
1263 ShelfID shelf_id = (id_map.begin() + 1)->first; 1262 ShelfID shelf_id = (id_map.begin() + 1)->first;
1264 views::View* button = (id_map.begin() + 1)->second; 1263 views::View* button = (id_map.begin() + 1)->second;
1265 1264
1266 // Replace the ShelfItemDelegate for |shelf_id| with one which tracks whether 1265 // Replace the ShelfItemDelegate for |shelf_id| with one which tracks whether
1267 // the shelf item gets selected. 1266 // the shelf item gets selected.
1268 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker; 1267 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker;
1269 item_manager_->SetShelfItemDelegate( 1268 item_manager_->SetShelfItemDelegate(
1270 shelf_id, 1269 shelf_id, scoped_ptr<ShelfItemDelegate>(selection_tracker));
1271 scoped_ptr<ShelfItemDelegate>(selection_tracker).Pass());
1272 1270
1273 gfx::Vector2d press_offset(5, 30); 1271 gfx::Vector2d press_offset(5, 30);
1274 gfx::Point press_location = gfx::Point() + press_offset; 1272 gfx::Point press_location = gfx::Point() + press_offset;
1275 gfx::Point press_location_in_screen = 1273 gfx::Point press_location_in_screen =
1276 button->GetBoundsInScreen().origin() + press_offset; 1274 button->GetBoundsInScreen().origin() + press_offset;
1277 1275
1278 ui::MouseEvent click_event(ui::ET_MOUSE_PRESSED, press_location, 1276 ui::MouseEvent click_event(ui::ET_MOUSE_PRESSED, press_location,
1279 press_location_in_screen, ui::EventTimeForNow(), 1277 press_location_in_screen, ui::EventTimeForNow(),
1280 ui::EF_LEFT_MOUSE_BUTTON, 0); 1278 ui::EF_LEFT_MOUSE_BUTTON, 0);
1281 button->OnMousePressed(click_event); 1279 button->OnMousePressed(click_event);
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
1867 1865
1868 // Verifies that Launcher_ButtonPressed_* UMA user actions are recorded when an 1866 // Verifies that Launcher_ButtonPressed_* UMA user actions are recorded when an
1869 // item is selected. 1867 // item is selected.
1870 TEST_F(ShelfViewTest, 1868 TEST_F(ShelfViewTest,
1871 Launcher_ButtonPressedUserActionsRecordedWhenItemSelected) { 1869 Launcher_ButtonPressedUserActionsRecordedWhenItemSelected) {
1872 base::UserActionTester user_action_tester; 1870 base::UserActionTester user_action_tester;
1873 1871
1874 ShelfID browser_shelf_id = model_->items()[browser_index_].id; 1872 ShelfID browser_shelf_id = model_->items()[browser_index_].id;
1875 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker; 1873 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker;
1876 item_manager_->SetShelfItemDelegate( 1874 item_manager_->SetShelfItemDelegate(
1877 browser_shelf_id, 1875 browser_shelf_id, scoped_ptr<ShelfItemDelegate>(selection_tracker));
1878 scoped_ptr<ShelfItemDelegate>(selection_tracker).Pass());
1879 1876
1880 SimulateClick(browser_index_); 1877 SimulateClick(browser_index_);
1881 EXPECT_EQ(1, 1878 EXPECT_EQ(1,
1882 user_action_tester.GetActionCount("Launcher_ButtonPressed_Mouse")); 1879 user_action_tester.GetActionCount("Launcher_ButtonPressed_Mouse"));
1883 } 1880 }
1884 1881
1885 // Verifies that Launcher_*Task UMA user actions are recorded when an item is 1882 // Verifies that Launcher_*Task UMA user actions are recorded when an item is
1886 // selected. 1883 // selected.
1887 TEST_F(ShelfViewTest, Launcher_TaskUserActionsRecordedWhenItemSelected) { 1884 TEST_F(ShelfViewTest, Launcher_TaskUserActionsRecordedWhenItemSelected) {
1888 base::UserActionTester user_action_tester; 1885 base::UserActionTester user_action_tester;
1889 1886
1890 ShelfID browser_shelf_id = model_->items()[browser_index_].id; 1887 ShelfID browser_shelf_id = model_->items()[browser_index_].id;
1891 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker; 1888 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker;
1892 selection_tracker->set_item_selected_action( 1889 selection_tracker->set_item_selected_action(
1893 ShelfItemDelegate::kNewWindowCreated); 1890 ShelfItemDelegate::kNewWindowCreated);
1894 item_manager_->SetShelfItemDelegate( 1891 item_manager_->SetShelfItemDelegate(
1895 browser_shelf_id, 1892 browser_shelf_id, scoped_ptr<ShelfItemDelegate>(selection_tracker));
1896 scoped_ptr<ShelfItemDelegate>(selection_tracker).Pass());
1897 1893
1898 SimulateClick(browser_index_); 1894 SimulateClick(browser_index_);
1899 EXPECT_EQ(1, user_action_tester.GetActionCount("Launcher_LaunchTask")); 1895 EXPECT_EQ(1, user_action_tester.GetActionCount("Launcher_LaunchTask"));
1900 } 1896 }
1901 1897
1902 // Verifies that metrics are recorded when an item is minimized and subsequently 1898 // Verifies that metrics are recorded when an item is minimized and subsequently
1903 // activated. 1899 // activated.
1904 TEST_F(ShelfViewTest, 1900 TEST_F(ShelfViewTest,
1905 VerifyMetricsAreRecordedWhenAnItemIsMinimizedAndActivated) { 1901 VerifyMetricsAreRecordedWhenAnItemIsMinimizedAndActivated) {
1906 base::HistogramTester histogram_tester; 1902 base::HistogramTester histogram_tester;
1907 1903
1908 ShelfID browser_shelf_id = model_->items()[browser_index_].id; 1904 ShelfID browser_shelf_id = model_->items()[browser_index_].id;
1909 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker; 1905 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker;
1910 item_manager_->SetShelfItemDelegate( 1906 item_manager_->SetShelfItemDelegate(
1911 browser_shelf_id, 1907 browser_shelf_id, scoped_ptr<ShelfItemDelegate>(selection_tracker));
1912 scoped_ptr<ShelfItemDelegate>(selection_tracker).Pass());
1913 1908
1914 selection_tracker->set_item_selected_action( 1909 selection_tracker->set_item_selected_action(
1915 ShelfItemDelegate::kExistingWindowMinimized); 1910 ShelfItemDelegate::kExistingWindowMinimized);
1916 SimulateClick(browser_index_); 1911 SimulateClick(browser_index_);
1917 1912
1918 selection_tracker->set_item_selected_action( 1913 selection_tracker->set_item_selected_action(
1919 ShelfItemDelegate::kExistingWindowActivated); 1914 ShelfItemDelegate::kExistingWindowActivated);
1920 SimulateClick(browser_index_); 1915 SimulateClick(browser_index_);
1921 1916
1922 histogram_tester.ExpectTotalCount( 1917 histogram_tester.ExpectTotalCount(
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1966 test_api_->RunMessageLoopUntilAnimationsDone(); 1961 test_api_->RunMessageLoopUntilAnimationsDone();
1967 CheckAllItemsAreInBounds(); 1962 CheckAllItemsAreInBounds();
1968 } 1963 }
1969 1964
1970 INSTANTIATE_TEST_CASE_P(LtrRtl, ShelfViewTextDirectionTest, testing::Bool()); 1965 INSTANTIATE_TEST_CASE_P(LtrRtl, ShelfViewTextDirectionTest, testing::Bool());
1971 INSTANTIATE_TEST_CASE_P(VisibleBounds, ShelfViewVisibleBoundsTest, 1966 INSTANTIATE_TEST_CASE_P(VisibleBounds, ShelfViewVisibleBoundsTest,
1972 testing::Bool()); 1967 testing::Bool());
1973 1968
1974 } // namespace test 1969 } // namespace test
1975 } // namespace ash 1970 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_unittest.cc ('k') | ash/shelf/shelf_window_watcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698