OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |