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

Side by Side Diff: chrome/browser/ui/tabs/tab_strip_model_unittest.cc

Issue 10938027: tabs: Make the vector in MockTabStripModelObserver own values instead of pointers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 "chrome/browser/ui/tabs/tab_strip_model.h" 5 #include "chrome/browser/ui/tabs/tab_strip_model.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 private: 255 private:
256 content::TestBrowserThread browser_thread_; 256 content::TestBrowserThread browser_thread_;
257 257
258 std::wstring test_dir_; 258 std::wstring test_dir_;
259 std::wstring profile_path_; 259 std::wstring profile_path_;
260 }; 260 };
261 261
262 class MockTabStripModelObserver : public TabStripModelObserver { 262 class MockTabStripModelObserver : public TabStripModelObserver {
263 public: 263 public:
264 MockTabStripModelObserver() 264 MockTabStripModelObserver()
265 : empty_(true), 265 : states_deleter_(NULL),
266 empty_(true),
266 model_(NULL) {} 267 model_(NULL) {}
267 explicit MockTabStripModelObserver(TabStripModel* model) 268 explicit MockTabStripModelObserver(TabStripModel* model)
268 : empty_(true), 269 : states_deleter_(&states_),
270 empty_(true),
269 model_(model) {} 271 model_(model) {}
270 virtual ~MockTabStripModelObserver() { 272 virtual ~MockTabStripModelObserver() {}
271 STLDeleteContainerPointers(states_.begin(), states_.end());
272 }
273 273
274 enum TabStripModelObserverAction { 274 enum TabStripModelObserverAction {
275 INSERT, 275 INSERT,
276 CLOSE, 276 CLOSE,
277 DETACH, 277 DETACH,
278 ACTIVATE, 278 ACTIVATE,
279 DEACTIVATE, 279 DEACTIVATE,
280 SELECT, 280 SELECT,
281 MOVE, 281 MOVE,
282 CHANGE, 282 CHANGE,
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 states_.push_back(s); 390 states_.push_back(s);
391 } 391 }
392 virtual void TabPinnedStateChanged(TabContents* contents, int index) { 392 virtual void TabPinnedStateChanged(TabContents* contents, int index) {
393 states_.push_back(new State(contents, index, PINNED)); 393 states_.push_back(new State(contents, index, PINNED));
394 } 394 }
395 virtual void TabStripEmpty() { 395 virtual void TabStripEmpty() {
396 empty_ = true; 396 empty_ = true;
397 } 397 }
398 398
399 void ClearStates() { 399 void ClearStates() {
400 STLDeleteContainerPointers(states_.begin(), states_.end()); 400 STLDeleteElements(&states_);
401 states_.clear();
402 } 401 }
403 402
404 bool empty() const { return empty_; } 403 bool empty() const { return empty_; }
405 TabStripModel* model() { return model_; } 404 TabStripModel* model() { return model_; }
406 405
407 private: 406 private:
408 std::vector<State*> states_; 407 std::vector<State*> states_;
sky 2012/09/20 15:03:26 If you're going to do anything, make this contain
tfarina 2012/09/21 01:18:55 Done.
408 STLElementDeleter<std::vector<State*> > states_deleter_;
409 409
410 bool empty_; 410 bool empty_;
411 TabStripModel* model_; 411 TabStripModel* model_;
412 412
413 DISALLOW_COPY_AND_ASSIGN(MockTabStripModelObserver); 413 DISALLOW_COPY_AND_ASSIGN(MockTabStripModelObserver);
414 }; 414 };
415 415
416 TEST_F(TabStripModelTest, TestBasicAPI) { 416 TEST_F(TabStripModelTest, TestBasicAPI) {
417 TabStripDummyDelegate delegate(NULL); 417 TabStripDummyDelegate delegate(NULL);
418 TabStripModel tabstrip(&delegate, profile()); 418 TabStripModel tabstrip(&delegate, profile());
(...skipping 2022 matching lines...) Expand 10 before | Expand all | Expand 10 after
2441 ASSERT_EQ(1, observer.GetStateCount()); 2441 ASSERT_EQ(1, observer.GetStateCount());
2442 MockTabStripModelObserver::State s( 2442 MockTabStripModelObserver::State s(
2443 contents2, 1, MockTabStripModelObserver::SELECT); 2443 contents2, 1, MockTabStripModelObserver::SELECT);
2444 s.src_contents = contents2; 2444 s.src_contents = contents2;
2445 s.src_index = 1; 2445 s.src_index = 1;
2446 s.user_gesture = false; 2446 s.user_gesture = false;
2447 EXPECT_TRUE(observer.StateEquals(0, s)); 2447 EXPECT_TRUE(observer.StateEquals(0, s));
2448 strip.RemoveObserver(&observer); 2448 strip.RemoveObserver(&observer);
2449 strip.CloseAllTabs(); 2449 strip.CloseAllTabs();
2450 } 2450 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698