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

Side by Side Diff: chrome/browser/ui/panels/base_panel_browser_test.cc

Issue 8872044: Add test cases for panel overflow handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/ui/panels/base_panel_browser_test.h" 5 #include "chrome/browser/ui/panels/base_panel_browser_test.h"
6 6
7 #include "chrome/browser/ui/browser_list.h" 7 #include "chrome/browser/ui/browser_list.h"
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/string_number_conversions.h"
14 #include "chrome/browser/extensions/extension_service.h" 15 #include "chrome/browser/extensions/extension_service.h"
15 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/browser.h" 17 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/panels/native_panel.h" 18 #include "chrome/browser/ui/panels/native_panel.h"
18 #include "chrome/browser/ui/panels/panel_manager.h" 19 #include "chrome/browser/ui/panels/panel_manager.h"
19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 20 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
20 #include "chrome/common/chrome_paths.h" 21 #include "chrome/common/chrome_paths.h"
21 #include "chrome/common/chrome_switches.h" 22 #include "chrome/common/chrome_switches.h"
22 #include "chrome/test/base/ui_test_utils.h" 23 #include "chrome/test/base/ui_test_utils.h"
23 #include "content/browser/tab_contents/test_tab_contents.h" 24 #include "content/browser/tab_contents/test_tab_contents.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 observer_->OnAutoHidingDesktopBarThicknessChanged(); 151 observer_->OnAutoHidingDesktopBarThicknessChanged();
151 } 152 }
152 153
153 bool ExistsPanel(Panel* panel) { 154 bool ExistsPanel(Panel* panel) {
154 const PanelManager::Panels& panels = PanelManager::GetInstance()->panels(); 155 const PanelManager::Panels& panels = PanelManager::GetInstance()->panels();
155 return find(panels.begin(), panels.end(), panel) != panels.end(); 156 return find(panels.begin(), panels.end(), panel) != panels.end();
156 } 157 }
157 158
158 } // namespace 159 } // namespace
159 160
161 PanelData::PanelData()
162 : panel(NULL),
163 expansion_state(Panel::EXPANDED),
164 visible(false),
165 active(false) {
166 }
167
168 PanelData::PanelData(Panel* panel)
169 : panel(panel),
170 name(panel->browser()->app_name()),
171 expansion_state(panel->expansion_state()),
172 visible(!panel->GetBounds().IsEmpty()),
173 active(panel->IsActive()) {
174 }
175
176 bool PanelData::operator==(const PanelData& another) const {
177 return panel == another.panel &&
178 expansion_state == another.expansion_state &&
179 visible == another.visible &&
180 active == another.active;
181 }
182
183 bool PanelData::operator!=(const PanelData& another) const {
184 return !(*this == another);
185 }
186
187 ::std::ostream& operator<<(::std::ostream& os, const PanelData& data) {
188 return os << "(" << data.name << ", " << data.expansion_state << ", "
189 << data.visible << ", " << data.active << ")";
190 }
191
192 PanelData* PanelDataList::get(Panel* panel) {
193 for (PanelDataList::iterator iter = begin(); iter != end(); ++iter) {
194 if (iter->panel == panel)
195 return &(*iter);
196 }
197 return NULL;
198 }
199
200 void PanelDataList::insertBefore(Panel* before_panel,
201 const PanelData& panel_data) {
202 for (PanelDataList::iterator iter = begin(); iter != end(); ++iter) {
203 if (iter->panel == before_panel) {
204 insert(iter, panel_data);
205 return;
206 }
207 }
208 }
209
210 PanelData PanelDataList::remove(Panel* panel) {
211 PanelData panel_data;
212 for (PanelDataList::iterator iter = begin(); iter != end(); ++iter) {
213 if (iter->panel == panel) {
214 panel_data = *iter;
215 erase(iter);
216 break;
217 }
218 }
219 return panel_data;
220 }
221
160 const FilePath::CharType* BasePanelBrowserTest::kTestDir = 222 const FilePath::CharType* BasePanelBrowserTest::kTestDir =
161 FILE_PATH_LITERAL("panels"); 223 FILE_PATH_LITERAL("panels");
162 224
163 BasePanelBrowserTest::BasePanelBrowserTest() 225 BasePanelBrowserTest::BasePanelBrowserTest()
164 : InProcessBrowserTest(), 226 : InProcessBrowserTest(),
165 testing_work_area_(0, 0, kTestingWorkAreaWidth, 227 testing_work_area_(0, 0, kTestingWorkAreaWidth,
166 kTestingWorkAreaHeight) { 228 kTestingWorkAreaHeight) {
167 #if defined(OS_MACOSX) 229 #if defined(OS_MACOSX)
168 FindBarBridge::disable_animations_during_testing_ = true; 230 FindBarBridge::disable_animations_during_testing_ = true;
169 #endif 231 #endif
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 std::string error; 434 std::string error;
373 scoped_refptr<Extension> extension = Extension::Create( 435 scoped_refptr<Extension> extension = Extension::Create(
374 full_path, location, *input_value, 436 full_path, location, *input_value,
375 Extension::STRICT_ERROR_CHECKS, &error); 437 Extension::STRICT_ERROR_CHECKS, &error);
376 EXPECT_TRUE(extension.get()); 438 EXPECT_TRUE(extension.get());
377 EXPECT_STREQ("", error.c_str()); 439 EXPECT_STREQ("", error.c_str());
378 browser()->GetProfile()->GetExtensionService()-> 440 browser()->GetProfile()->GetExtensionService()->
379 OnExtensionInstalled(extension.get(), false, -1); 441 OnExtensionInstalled(extension.get(), false, -1);
380 return extension; 442 return extension;
381 } 443 }
444
445 std::string BasePanelBrowserTest::GetPanelName(int index) {
446 std::string panel_name("Panel");
447 return panel_name + base::IntToString(index);
448 }
449
450 PanelDataList BasePanelBrowserTest::GetAllPanelData() {
451 PanelDataList panel_data_list;
452 std::vector<Panel*> panels = PanelManager::GetInstance()->panels();
453 for (std::vector<Panel*>::const_iterator iter = panels.begin();
454 iter != panels.end(); ++iter) {
455 Panel* panel = *iter;
456 panel_data_list.push_back(PanelData(panel));
457 }
458 return panel_data_list;
459 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698