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

Unified Diff: chrome/browser/tabs/tab_strip_model_unittest.cc

Issue 100210: Relanding in-progress download bug fix (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/tabs/tab_strip_model.cc ('k') | chrome/browser/views/tabs/tab_strip.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/tabs/tab_strip_model_unittest.cc
===================================================================
--- chrome/browser/tabs/tab_strip_model_unittest.cc (revision 14949)
+++ chrome/browser/tabs/tab_strip_model_unittest.cc (working copy)
@@ -22,9 +22,11 @@
class TabStripDummyDelegate : public TabStripModelDelegate {
public:
explicit TabStripDummyDelegate(TabContents* dummy)
- : dummy_contents_(dummy) {}
+ : dummy_contents_(dummy), can_close_(true) {}
virtual ~TabStripDummyDelegate() {}
+ void set_can_close(bool value) { can_close_ = value; }
+
// Overridden from TabStripModelDelegate:
virtual TabContents* AddBlankTab(bool foreground) { return NULL; }
virtual TabContents* AddBlankTabAt(int index, bool foreground) {
@@ -56,12 +58,16 @@
}
virtual bool CanRestoreTab() { return false; }
virtual void RestoreTab() {}
+ virtual bool CanCloseContentsAt(int index) { return can_close_ ; }
private:
// A dummy TabContents we give to callers that expect us to actually build a
// Destinations tab for them.
TabContents* dummy_contents_;
+ // Whether tabs can be closed.
+ bool can_close_;
+
DISALLOW_EVIL_CONSTRUCTORS(TabStripDummyDelegate);
};
@@ -311,7 +317,15 @@
// Test CloseTabContentsAt
{
- tabstrip.CloseTabContentsAt(2);
+ // Let's test nothing happens when the delegate veto the close.
+ delegate.set_can_close(false);
+ EXPECT_FALSE(tabstrip.CloseTabContentsAt(2));
+ EXPECT_EQ(3, tabstrip.count());
+ EXPECT_EQ(0, observer.GetStateCount());
+
+ // Now let's close for real.
+ delegate.set_can_close(true);
+ EXPECT_TRUE(tabstrip.CloseTabContentsAt(2));
EXPECT_EQ(2, tabstrip.count());
EXPECT_EQ(3, observer.GetStateCount());
« no previous file with comments | « chrome/browser/tabs/tab_strip_model.cc ('k') | chrome/browser/views/tabs/tab_strip.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698