| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 54   int transition_end_count() const { return transition_end_count_; } | 54   int transition_end_count() const { return transition_end_count_; } | 
| 55 | 55 | 
| 56  private: | 56  private: | 
| 57   void AppendSelectedPage(int page) { | 57   void AppendSelectedPage(int page) { | 
| 58     if (selected_pages_.length()) | 58     if (selected_pages_.length()) | 
| 59       selected_pages_.append(std::string(" ")); | 59       selected_pages_.append(std::string(" ")); | 
| 60     selected_pages_.append(base::StringPrintf("%d", page)); | 60     selected_pages_.append(base::StringPrintf("%d", page)); | 
| 61   } | 61   } | 
| 62 | 62 | 
| 63   // PaginationModelObserver overrides: | 63   // PaginationModelObserver overrides: | 
| 64   virtual void TotalPagesChanged() OVERRIDE {} | 64   virtual void TotalPagesChanged() override {} | 
| 65   virtual void SelectedPageChanged(int old_selected, | 65   virtual void SelectedPageChanged(int old_selected, | 
| 66                                    int new_selected) OVERRIDE { | 66                                    int new_selected) override { | 
| 67     AppendSelectedPage(new_selected); | 67     AppendSelectedPage(new_selected); | 
| 68     ++selection_count_; | 68     ++selection_count_; | 
| 69     if (expected_page_selection_ && | 69     if (expected_page_selection_ && | 
| 70         selection_count_ == expected_page_selection_) { | 70         selection_count_ == expected_page_selection_) { | 
| 71       base::MessageLoop::current()->Quit(); | 71       base::MessageLoop::current()->Quit(); | 
| 72     } | 72     } | 
| 73   } | 73   } | 
| 74 | 74 | 
| 75   virtual void TransitionStarted() OVERRIDE { | 75   virtual void TransitionStarted() override { | 
| 76   } | 76   } | 
| 77 | 77 | 
| 78   virtual void TransitionChanged() OVERRIDE { | 78   virtual void TransitionChanged() override { | 
| 79     if (transition_page_ == -1 || | 79     if (transition_page_ == -1 || | 
| 80         model_->transition().target_page == transition_page_) { | 80         model_->transition().target_page == transition_page_) { | 
| 81       if (model_->transition().progress == 0) | 81       if (model_->transition().progress == 0) | 
| 82         ++transition_start_count_; | 82         ++transition_start_count_; | 
| 83       if (model_->transition().progress == 1) | 83       if (model_->transition().progress == 1) | 
| 84         ++transition_end_count_; | 84         ++transition_end_count_; | 
| 85     } | 85     } | 
| 86 | 86 | 
| 87     if ((expected_transition_start_ && | 87     if ((expected_transition_start_ && | 
| 88          transition_start_count_ == expected_transition_start_) || | 88          transition_start_count_ == expected_transition_start_) || | 
| (...skipping 21 matching lines...) Expand all  Loading... | 
| 110 | 110 | 
| 111   DISALLOW_COPY_AND_ASSIGN(TestPaginationModelObserver); | 111   DISALLOW_COPY_AND_ASSIGN(TestPaginationModelObserver); | 
| 112 }; | 112 }; | 
| 113 | 113 | 
| 114 class PaginationModelTest : public testing::Test { | 114 class PaginationModelTest : public testing::Test { | 
| 115  public: | 115  public: | 
| 116   PaginationModelTest() {} | 116   PaginationModelTest() {} | 
| 117   virtual ~PaginationModelTest() {} | 117   virtual ~PaginationModelTest() {} | 
| 118 | 118 | 
| 119   // testing::Test overrides: | 119   // testing::Test overrides: | 
| 120   virtual void SetUp() OVERRIDE { | 120   virtual void SetUp() override { | 
| 121     pagination_.SetTotalPages(5); | 121     pagination_.SetTotalPages(5); | 
| 122     pagination_.SetTransitionDurations(1, 1); | 122     pagination_.SetTransitionDurations(1, 1); | 
| 123     observer_.set_model(&pagination_); | 123     observer_.set_model(&pagination_); | 
| 124     pagination_.AddObserver(&observer_); | 124     pagination_.AddObserver(&observer_); | 
| 125   } | 125   } | 
| 126   virtual void TearDown() OVERRIDE { | 126   virtual void TearDown() override { | 
| 127     pagination_.RemoveObserver(&observer_); | 127     pagination_.RemoveObserver(&observer_); | 
| 128     observer_.set_model(NULL); | 128     observer_.set_model(NULL); | 
| 129   } | 129   } | 
| 130 | 130 | 
| 131  protected: | 131  protected: | 
| 132   void SetStartPageAndExpects(int start_page, | 132   void SetStartPageAndExpects(int start_page, | 
| 133                               int expected_selection, | 133                               int expected_selection, | 
| 134                               int expected_transition_start, | 134                               int expected_transition_start, | 
| 135                               int expected_transition_end) { | 135                               int expected_transition_end) { | 
| 136     observer_.set_expected_page_selection(0); | 136     observer_.set_expected_page_selection(0); | 
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 425   EXPECT_EQ(1, pagination_.selected_page()); | 425   EXPECT_EQ(1, pagination_.selected_page()); | 
| 426 | 426 | 
| 427   // But if the currently selected_page exceeds the total number of pages, | 427   // But if the currently selected_page exceeds the total number of pages, | 
| 428   // it automatically switches to the last page. | 428   // it automatically switches to the last page. | 
| 429   pagination_.SetTotalPages(1); | 429   pagination_.SetTotalPages(1); | 
| 430   EXPECT_EQ(0, pagination_.selected_page()); | 430   EXPECT_EQ(0, pagination_.selected_page()); | 
| 431 } | 431 } | 
| 432 | 432 | 
| 433 }  // namespace test | 433 }  // namespace test | 
| 434 }  // namespace app_list | 434 }  // namespace app_list | 
| OLD | NEW | 
|---|