| OLD | NEW |
| 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 "ui/app_list/pagination_model.h" | 5 #include "ui/app_list/pagination_model.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 selected_pages_.append(base::IntToString(page)); | 60 selected_pages_.append(base::IntToString(page)); |
| 61 } | 61 } |
| 62 | 62 |
| 63 // PaginationModelObserver overrides: | 63 // PaginationModelObserver overrides: |
| 64 void TotalPagesChanged() override {} | 64 void TotalPagesChanged() override {} |
| 65 void SelectedPageChanged(int old_selected, int new_selected) override { | 65 void SelectedPageChanged(int old_selected, int new_selected) override { |
| 66 AppendSelectedPage(new_selected); | 66 AppendSelectedPage(new_selected); |
| 67 ++selection_count_; | 67 ++selection_count_; |
| 68 if (expected_page_selection_ && | 68 if (expected_page_selection_ && |
| 69 selection_count_ == expected_page_selection_) { | 69 selection_count_ == expected_page_selection_) { |
| 70 base::MessageLoop::current()->Quit(); | 70 base::MessageLoop::current()->QuitWhenIdle(); |
| 71 } | 71 } |
| 72 } | 72 } |
| 73 | 73 |
| 74 void TransitionStarted() override {} | 74 void TransitionStarted() override {} |
| 75 | 75 |
| 76 void TransitionChanged() override { | 76 void TransitionChanged() override { |
| 77 if (transition_page_ == -1 || | 77 if (transition_page_ == -1 || |
| 78 model_->transition().target_page == transition_page_) { | 78 model_->transition().target_page == transition_page_) { |
| 79 if (model_->transition().progress == 0) | 79 if (model_->transition().progress == 0) |
| 80 ++transition_start_count_; | 80 ++transition_start_count_; |
| 81 if (model_->transition().progress == 1) | 81 if (model_->transition().progress == 1) |
| 82 ++transition_end_count_; | 82 ++transition_end_count_; |
| 83 } | 83 } |
| 84 | 84 |
| 85 if ((expected_transition_start_ && | 85 if ((expected_transition_start_ && |
| 86 transition_start_count_ == expected_transition_start_) || | 86 transition_start_count_ == expected_transition_start_) || |
| 87 (expected_transition_end_ && | 87 (expected_transition_end_ && |
| 88 transition_end_count_ == expected_transition_end_)) { | 88 transition_end_count_ == expected_transition_end_)) { |
| 89 base::MessageLoop::current()->Quit(); | 89 base::MessageLoop::current()->QuitWhenIdle(); |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 | 92 |
| 93 PaginationModel* model_; | 93 PaginationModel* model_; |
| 94 | 94 |
| 95 int expected_page_selection_; | 95 int expected_page_selection_; |
| 96 int expected_transition_start_; | 96 int expected_transition_start_; |
| 97 int expected_transition_end_; | 97 int expected_transition_end_; |
| 98 | 98 |
| 99 int selection_count_; | 99 int selection_count_; |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 EXPECT_EQ(1, pagination_.selected_page()); | 423 EXPECT_EQ(1, pagination_.selected_page()); |
| 424 | 424 |
| 425 // But if the currently selected_page exceeds the total number of pages, | 425 // But if the currently selected_page exceeds the total number of pages, |
| 426 // it automatically switches to the last page. | 426 // it automatically switches to the last page. |
| 427 pagination_.SetTotalPages(1); | 427 pagination_.SetTotalPages(1); |
| 428 EXPECT_EQ(0, pagination_.selected_page()); | 428 EXPECT_EQ(0, pagination_.selected_page()); |
| 429 } | 429 } |
| 430 | 430 |
| 431 } // namespace test | 431 } // namespace test |
| 432 } // namespace app_list | 432 } // namespace app_list |
| OLD | NEW |