This source file includes following definitions.
- other_
- WebContentsDestroyed
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "content/public/browser/invalidate_type.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
typedef InProcessBrowserTest BrowserViewTest;
namespace {
class TestWebContentsObserver : public content::WebContentsObserver {
public:
TestWebContentsObserver(content::WebContents* source,
content::WebContents* other)
: content::WebContentsObserver(source),
other_(other) {}
virtual ~TestWebContentsObserver() {}
virtual void WebContentsDestroyed(
content::WebContents* web_contents) OVERRIDE {
other_->NotifyNavigationStateChanged(
content::INVALIDATE_TYPE_URL | content::INVALIDATE_TYPE_LOAD);
}
private:
content::WebContents* other_;
DISALLOW_COPY_AND_ASSIGN(TestWebContentsObserver);
};
}
IN_PROC_BROWSER_TEST_F(BrowserViewTest, CloseWithTabs) {
Browser* browser2 =
new Browser(Browser::CreateParams(browser()->profile(),
browser()->host_desktop_type()));
chrome::AddTabAt(browser2, GURL(), -1, true);
chrome::AddTabAt(browser2, GURL(), -1, true);
TestWebContentsObserver observer(
browser2->tab_strip_model()->GetWebContentsAt(0),
browser2->tab_strip_model()->GetWebContentsAt(1));
BrowserView::GetBrowserViewForBrowser(browser2)->GetWidget()->CloseNow();
}
IN_PROC_BROWSER_TEST_F(BrowserViewTest, CloseWithTabsStartWithActive) {
Browser* browser2 =
new Browser(Browser::CreateParams(browser()->profile(),
browser()->host_desktop_type()));
chrome::AddTabAt(browser2, GURL(), -1, true);
chrome::AddTabAt(browser2, GURL(), -1, true);
browser2->tab_strip_model()->ActivateTabAt(0, true);
TestWebContentsObserver observer(
browser2->tab_strip_model()->GetWebContentsAt(0),
browser2->tab_strip_model()->GetWebContentsAt(1));
BrowserView::GetBrowserViewForBrowser(browser2)->GetWidget()->CloseNow();
}