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

Side by Side Diff: ui/message_center/views/message_center_view.cc

Issue 2554903003: Add unittest for MessageListView (Closed)
Patch Set: fixed the build failrue on win Created 4 years 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "ui/message_center/views/message_center_view.h" 5 #include "ui/message_center/views/message_center_view.h"
6 6
7 #include <list> 7 #include <list>
8 #include <map> 8 #include <map>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 scroller_ = new views::ScrollView(); 97 scroller_ = new views::ScrollView();
98 scroller_->ClipHeightTo(kMinScrollViewHeight, max_height - button_height); 98 scroller_->ClipHeightTo(kMinScrollViewHeight, max_height - button_height);
99 scroller_->SetVerticalScrollBar(new views::OverlayScrollBar(false)); 99 scroller_->SetVerticalScrollBar(new views::OverlayScrollBar(false));
100 scroller_->set_background( 100 scroller_->set_background(
101 views::Background::CreateSolidBackground(kMessageCenterBackgroundColor)); 101 views::Background::CreateSolidBackground(kMessageCenterBackgroundColor));
102 102
103 scroller_->SetPaintToLayer(true); 103 scroller_->SetPaintToLayer(true);
104 scroller_->layer()->SetFillsBoundsOpaquely(false); 104 scroller_->layer()->SetFillsBoundsOpaquely(false);
105 scroller_->layer()->SetMasksToBounds(true); 105 scroller_->layer()->SetMasksToBounds(true);
106 106
107 message_list_view_.reset(new MessageListView(this, top_down)); 107 message_list_view_.reset(new MessageListView(top_down));
108 message_list_view_->set_owned_by_client(); 108 message_list_view_->set_owned_by_client();
109 message_list_view_->AddObserver(this);
109 110
110 // We want to swap the contents of the scroll view between the empty list 111 // We want to swap the contents of the scroll view between the empty list
111 // view and the message list view, without constructing them afresh each 112 // view and the message list view, without constructing them afresh each
112 // time. So, since the scroll view deletes old contents each time you 113 // time. So, since the scroll view deletes old contents each time you
113 // set the contents (regardless of the |owned_by_client_| setting) we need 114 // set the contents (regardless of the |owned_by_client_| setting) we need
114 // an intermediate view for the contents whose children we can swap in and 115 // an intermediate view for the contents whose children we can swap in and
115 // out. 116 // out.
116 views::View* scroller_contents = new views::View(); 117 views::View* scroller_contents = new views::View();
117 scroller_contents->SetLayoutManager(new views::FillLayout()); 118 scroller_contents->SetLayoutManager(new views::FillLayout());
118 scroller_contents->AddChildView(message_list_view_.get()); 119 scroller_contents->AddChildView(message_list_view_.get());
119 scroller_->SetContents(scroller_contents); 120 scroller_->SetContents(scroller_contents);
120 121
121 settings_view_ = new NotifierSettingsView(notifier_settings_provider); 122 settings_view_ = new NotifierSettingsView(notifier_settings_provider);
122 123
123 scroller_->SetVisible(false); // Because it has no notifications at first. 124 scroller_->SetVisible(false); // Because it has no notifications at first.
124 settings_view_->SetVisible(mode_ == Mode::SETTINGS); 125 settings_view_->SetVisible(mode_ == Mode::SETTINGS);
125 126
126 AddChildView(scroller_); 127 AddChildView(scroller_);
127 AddChildView(settings_view_); 128 AddChildView(settings_view_);
128 AddChildView(button_bar_); 129 AddChildView(button_bar_);
129 } 130 }
130 131
131 MessageCenterView::~MessageCenterView() { 132 MessageCenterView::~MessageCenterView() {
133 message_list_view_->RemoveObserver(this);
134
132 if (!is_closing_) 135 if (!is_closing_)
133 message_center_->RemoveObserver(this); 136 message_center_->RemoveObserver(this);
134 } 137 }
135 138
136 void MessageCenterView::SetNotifications( 139 void MessageCenterView::SetNotifications(
137 const NotificationList::Notifications& notifications) { 140 const NotificationList::Notifications& notifications) {
138 if (is_closing_) 141 if (is_closing_)
139 return; 142 return;
140 143
141 notification_views_.clear(); 144 notification_views_.clear();
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 // Disable the close-all button since no notification is visible. 642 // Disable the close-all button since no notification is visible.
640 button_bar_->SetCloseAllButtonEnabled(false); 643 button_bar_->SetCloseAllButtonEnabled(false);
641 } 644 }
642 } 645 }
643 646
644 void MessageCenterView::SetNotificationViewForTest(MessageView* view) { 647 void MessageCenterView::SetNotificationViewForTest(MessageView* view) {
645 message_list_view_->AddNotificationAt(view, 0); 648 message_list_view_->AddNotificationAt(view, 0);
646 } 649 }
647 650
648 } // namespace message_center 651 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/message_center/views/message_center_view.h ('k') | ui/message_center/views/message_list_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698