| Index: chrome/browser/ui/tabs/tab_strip_model_unittest.cc
|
| diff --git a/chrome/browser/ui/tabs/tab_strip_model_unittest.cc b/chrome/browser/ui/tabs/tab_strip_model_unittest.cc
|
| index f040375f844bf6032b3b6167f6aa9f4a93631bdf..9614db3626cee1a6adf3f0e86ad5409c4169fad0 100644
|
| --- a/chrome/browser/ui/tabs/tab_strip_model_unittest.cc
|
| +++ b/chrome/browser/ui/tabs/tab_strip_model_unittest.cc
|
| @@ -38,6 +38,7 @@
|
| #include "content/public/browser/web_contents_observer.h"
|
| #include "content/public/test/web_contents_tester.h"
|
| #include "extensions/common/extension.h"
|
| +#include "testing/gmock/include/gmock/gmock.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| using content::SiteInstance;
|
| @@ -432,6 +433,15 @@ class MockTabStripModelObserver : public TabStripModelObserver {
|
| DISALLOW_COPY_AND_ASSIGN(MockTabStripModelObserver);
|
| };
|
|
|
| +class MockWebContentsObserver : public content::WebContentsObserver {
|
| + public:
|
| + explicit MockWebContentsObserver(WebContents* web_contents)
|
| + : WebContentsObserver(web_contents) {}
|
| + MOCK_METHOD2(
|
| + WebContentsReplaced,
|
| + void(WebContents* old_web_contents, WebContents* new_web_contents));
|
| +};
|
| +
|
| TEST_F(TabStripModelTest, TestBasicAPI) {
|
| TabStripDummyDelegate delegate;
|
| TabStripModel tabstrip(&delegate, profile());
|
| @@ -2124,6 +2134,22 @@ TEST_F(TabStripModelTest, ReplaceSendsSelected) {
|
| strip.CloseAllTabs();
|
| }
|
|
|
| +// Makes sure the TabStripModel notifies a WebContents during its replacement.
|
| +TEST_F(TabStripModelTest, ReplaceNotifiesWebContents) {
|
| + TabStripDummyDelegate delegate;
|
| + TabStripModel strip(&delegate, profile());
|
| +
|
| + WebContents* contents1 = CreateWebContents();
|
| + WebContents* contents2 = CreateWebContents();
|
| + strip.AppendWebContents(contents1, true);
|
| +
|
| + MockWebContentsObserver observer(contents1);
|
| + EXPECT_CALL(observer, WebContentsReplaced(contents1, contents2));
|
| + delete strip.ReplaceWebContentsAt(0, contents2);
|
| +
|
| + strip.CloseAllTabs();
|
| +}
|
| +
|
| // Makes sure TabStripModel handles the case of deleting a tab while removing
|
| // another tab.
|
| TEST_F(TabStripModelTest, DeleteFromDestroy) {
|
|
|