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

Side by Side Diff: ui/app_list/pagination_model_unittest.cc

Issue 667923002: Standardize usage of virtual/override/final in ui/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 | « ui/app_list/pagination_model.h ('k') | ui/app_list/search/dictionary_data_store.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 (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"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "ui/app_list/pagination_model_observer.h" 14 #include "ui/app_list/pagination_model_observer.h"
15 15
16 namespace app_list { 16 namespace app_list {
17 namespace test { 17 namespace test {
18 18
19 class TestPaginationModelObserver : public PaginationModelObserver { 19 class TestPaginationModelObserver : public PaginationModelObserver {
20 public: 20 public:
21 TestPaginationModelObserver() 21 TestPaginationModelObserver()
22 : model_(NULL), 22 : model_(NULL),
23 expected_page_selection_(0), 23 expected_page_selection_(0),
24 expected_transition_start_(0), 24 expected_transition_start_(0),
25 expected_transition_end_(0), 25 expected_transition_end_(0),
26 transition_page_(-1) { 26 transition_page_(-1) {
27 Reset(); 27 Reset();
28 } 28 }
29 virtual ~TestPaginationModelObserver() {} 29 ~TestPaginationModelObserver() override {}
30 30
31 void Reset() { 31 void Reset() {
32 selection_count_ = 0; 32 selection_count_ = 0;
33 transition_start_count_ = 0; 33 transition_start_count_ = 0;
34 transition_end_count_ = 0; 34 transition_end_count_ = 0;
35 selected_pages_.clear(); 35 selected_pages_.clear();
36 } 36 }
37 37
38 void set_model(PaginationModel* model) { model_ = model; } 38 void set_model(PaginationModel* model) { model_ = model; }
39 39
(...skipping 14 matching lines...) Expand all
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 void TotalPagesChanged() override {}
65 virtual void SelectedPageChanged(int old_selected, 65 void SelectedPageChanged(int old_selected, int new_selected) override {
66 int new_selected) override {
67 AppendSelectedPage(new_selected); 66 AppendSelectedPage(new_selected);
68 ++selection_count_; 67 ++selection_count_;
69 if (expected_page_selection_ && 68 if (expected_page_selection_ &&
70 selection_count_ == expected_page_selection_) { 69 selection_count_ == expected_page_selection_) {
71 base::MessageLoop::current()->Quit(); 70 base::MessageLoop::current()->Quit();
72 } 71 }
73 } 72 }
74 73
75 virtual void TransitionStarted() override { 74 void TransitionStarted() override {}
76 }
77 75
78 virtual void TransitionChanged() override { 76 void TransitionChanged() override {
79 if (transition_page_ == -1 || 77 if (transition_page_ == -1 ||
80 model_->transition().target_page == transition_page_) { 78 model_->transition().target_page == transition_page_) {
81 if (model_->transition().progress == 0) 79 if (model_->transition().progress == 0)
82 ++transition_start_count_; 80 ++transition_start_count_;
83 if (model_->transition().progress == 1) 81 if (model_->transition().progress == 1)
84 ++transition_end_count_; 82 ++transition_end_count_;
85 } 83 }
86 84
87 if ((expected_transition_start_ && 85 if ((expected_transition_start_ &&
88 transition_start_count_ == expected_transition_start_) || 86 transition_start_count_ == expected_transition_start_) ||
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 EXPECT_EQ(1, pagination_.selected_page()); 423 EXPECT_EQ(1, pagination_.selected_page());
426 424
427 // 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,
428 // it automatically switches to the last page. 426 // it automatically switches to the last page.
429 pagination_.SetTotalPages(1); 427 pagination_.SetTotalPages(1);
430 EXPECT_EQ(0, pagination_.selected_page()); 428 EXPECT_EQ(0, pagination_.selected_page());
431 } 429 }
432 430
433 } // namespace test 431 } // namespace test
434 } // namespace app_list 432 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/pagination_model.h ('k') | ui/app_list/search/dictionary_data_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698