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

Side by Side Diff: ui/app_list/cocoa/apps_grid_controller_unittest.mm

Issue 187483005: Extending the Views-on-Mac experiment: whole app list grid. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: still compiles r263560 + crrev/195793005 Created 6 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 | Annotate | Revision Log
« no previous file with comments | « ui/app_list/cocoa/apps_grid_controller.mm ('k') | ui/app_list/cocoa/apps_grid_view_item.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/mac/foundation_util.h" 5 #include "base/mac/foundation_util.h"
6 #include "base/mac/scoped_nsobject.h" 6 #include "base/mac/scoped_nsobject.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "skia/ext/skia_utils_mac.h" 8 #include "skia/ext/skia_utils_mac.h"
9 #import "testing/gtest_mac.h" 9 #import "testing/gtest_mac.h"
10 #include "ui/app_list/app_list_constants.h" 10 #include "ui/app_list/app_list_constants.h"
11 #include "ui/app_list/app_list_item.h" 11 #include "ui/app_list/app_list_item.h"
12 #import "ui/app_list/cocoa/apps_collection_view_drag_manager.h" 12 #import "ui/app_list/cocoa/apps_collection_view_drag_manager.h"
13 #import "ui/app_list/cocoa/apps_grid_controller.h" 13 #import "ui/app_list/cocoa/apps_grid_controller.h"
14 #import "ui/app_list/cocoa/apps_grid_view_item.h" 14 #import "ui/app_list/cocoa/apps_grid_view_item.h"
15 #import "ui/app_list/cocoa/apps_pagination_model_observer.h" 15 #import "ui/app_list/cocoa/apps_pagination_model_observer.h"
16 #import "ui/app_list/cocoa/test/apps_grid_controller_test_helper.h" 16 #import "ui/app_list/cocoa/test/apps_grid_controller_test_helper.h"
17 #include "ui/app_list/test/app_list_test_model.h" 17 #include "ui/app_list/test/app_list_test_model.h"
18 #include "ui/app_list/test/app_list_test_view_delegate.h" 18 #include "ui/app_list/test/app_list_test_view_delegate.h"
19 #include "ui/app_list/views/progress_bar_view.h"
19 #include "ui/base/models/simple_menu_model.h" 20 #include "ui/base/models/simple_menu_model.h"
20 #import "ui/events/test/cocoa_test_event_utils.h" 21 #import "ui/events/test/cocoa_test_event_utils.h"
21 22
22 @interface TestPaginationObserver : NSObject<AppsPaginationModelObserver> { 23 @interface TestPaginationObserver : NSObject<AppsPaginationModelObserver> {
23 @private 24 @private
24 NSInteger hoveredSegmentForTest_; 25 NSInteger hoveredSegmentForTest_;
25 int totalPagesChangedCount_; 26 int totalPagesChangedCount_;
26 int selectedPageChangedCount_; 27 int selectedPageChangedCount_;
27 int lastNewSelectedPage_; 28 int lastNewSelectedPage_;
28 bool visibilityDidChange_; 29 bool visibilityDidChange_;
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 NSButton* button = GetItemViewAt(kItemsPerPage); 574 NSButton* button = GetItemViewAt(kItemsPerPage);
574 NSView* containerView = [button superview]; 575 NSView* containerView = [button superview];
575 EXPECT_EQ(1u, [[containerView subviews] count]); 576 EXPECT_EQ(1u, [[containerView subviews] count]);
576 EXPECT_NSEQ(@"Item 16", [button title]); 577 EXPECT_NSEQ(@"Item 16", [button title]);
577 item_model->SetHighlighted(true); 578 item_model->SetHighlighted(true);
578 item_model->SetIsInstalling(true); 579 item_model->SetIsInstalling(true);
579 EXPECT_EQ(1u, [apps_grid_controller_ visiblePage]); 580 EXPECT_EQ(1u, [apps_grid_controller_ visiblePage]);
580 581
581 EXPECT_EQ(2u, [[containerView subviews] count]); 582 EXPECT_EQ(2u, [[containerView subviews] count]);
582 EXPECT_NSEQ(@"", [button title]); 583 EXPECT_NSEQ(@"", [button title]);
583 NSProgressIndicator* progressIndicator = 584 app_list::ProgressBarView* progressBar =
584 [[containerView subviews] objectAtIndex:1]; 585 [[apps_grid_controller_ itemAtIndex:kItemsPerPage] progressIndicator];
585 EXPECT_FALSE([progressIndicator isIndeterminate]); 586 // TODO(tapted): Check for indeterminate:NO.
586 EXPECT_EQ(0.0, [progressIndicator doubleValue]); 587 EXPECT_EQ(0.0, progressBar->current_value());
587 588
588 // Updating the progress in the model should update the progress bar. 589 // Updating the progress in the model should update the progress bar.
589 item_model->SetPercentDownloaded(50); 590 item_model->SetPercentDownloaded(50);
590 EXPECT_EQ(50.0, [progressIndicator doubleValue]); 591 EXPECT_EQ(0.5, progressBar->current_value());
591 592
592 // Two things can be installing simultaneously. When one starts or completes 593 // Two things can be installing simultaneously. When one starts or completes
593 // the model builder will ask for the item to be highlighted. 594 // the model builder will ask for the item to be highlighted.
594 app_list::AppListItem* alternate_item_model = 595 app_list::AppListItem* alternate_item_model =
595 model()->top_level_item_list()->item_at(0); 596 model()->top_level_item_list()->item_at(0);
596 item_model->SetHighlighted(false); 597 item_model->SetHighlighted(false);
597 alternate_item_model->SetHighlighted(true); 598 alternate_item_model->SetHighlighted(true);
598 EXPECT_EQ(0u, [apps_grid_controller_ visiblePage]); 599 EXPECT_EQ(0u, [apps_grid_controller_ visiblePage]);
599 600
600 // Update the first item (page doesn't change on updates). 601 // Update the first item (page doesn't change on updates).
601 item_model->SetPercentDownloaded(100); 602 item_model->SetPercentDownloaded(100);
602 EXPECT_EQ(100.0, [progressIndicator doubleValue]); 603 EXPECT_EQ(1.0, progressBar->current_value());
603 EXPECT_EQ(0u, [apps_grid_controller_ visiblePage]); 604 EXPECT_EQ(0u, [apps_grid_controller_ visiblePage]);
604 605
605 // A percent of -1 indicates the download is complete and the unpack/install 606 // A percent of -1 indicates the download is complete and the unpack/install
606 // process has started. 607 // process has started.
607 item_model->SetPercentDownloaded(-1); 608 item_model->SetPercentDownloaded(-1);
608 EXPECT_TRUE([progressIndicator isIndeterminate]); 609 // TODO(tapted): Check for indeterminate:YES.
609 610
610 // Completing install removes the progress bar, and restores the title. 611 // Completing install removes the progress bar, and restores the title.
611 // ExtensionAppModelBuilder will reload the ExtensionAppItem, which also 612 // ExtensionAppModelBuilder will reload the ExtensionAppItem, which also
612 // highlights. Do the same here. 613 // highlights. Do the same here.
613 alternate_item_model->SetHighlighted(false); 614 alternate_item_model->SetHighlighted(false);
614 item_model->SetHighlighted(true); 615 item_model->SetHighlighted(true);
615 item_model->SetIsInstalling(false); 616 item_model->SetIsInstalling(false);
616 EXPECT_EQ(1u, [[containerView subviews] count]); 617 EXPECT_EQ(1u, [[containerView subviews] count]);
617 EXPECT_NSEQ(@"Item 16", [button title]); 618 EXPECT_NSEQ(@"Item 16", [button title]);
618 EXPECT_EQ(1u, [apps_grid_controller_ visiblePage]); 619 EXPECT_EQ(1u, [apps_grid_controller_ visiblePage]);
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 // Test that a button being held down with the left button does not also show 989 // Test that a button being held down with the left button does not also show
989 // a context menu. 990 // a context menu.
990 [GetItemViewAt(0) highlight:YES]; 991 [GetItemViewAt(0) highlight:YES];
991 EXPECT_FALSE([page menuForEvent:mouse_at_cell_0]); 992 EXPECT_FALSE([page menuForEvent:mouse_at_cell_0]);
992 [GetItemViewAt(0) highlight:NO]; 993 [GetItemViewAt(0) highlight:NO];
993 EXPECT_TRUE([page menuForEvent:mouse_at_cell_0]); 994 EXPECT_TRUE([page menuForEvent:mouse_at_cell_0]);
994 } 995 }
995 996
996 } // namespace test 997 } // namespace test
997 } // namespace app_list 998 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/cocoa/apps_grid_controller.mm ('k') | ui/app_list/cocoa/apps_grid_view_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698