This source file includes following definitions.
- CountAllBrowsers
- TEST_F
- TEST_F
- TEST_F
- TEST
#include "chrome/browser/ui/browser_iterator.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/host_desktop.h"
#include "chrome/test/base/browser_with_test_window_test.h"
typedef BrowserWithTestWindowTest BrowserIteratorTest;
namespace {
class BrowserIteratorTestWithInitialWindowInAsh
: public BrowserWithTestWindowTest {
public:
BrowserIteratorTestWithInitialWindowInAsh()
: BrowserWithTestWindowTest(Browser::TYPE_TABBED,
chrome::HOST_DESKTOP_TYPE_ASH,
false) {
}
};
size_t CountAllBrowsers() {
size_t count = 0;
for (chrome::BrowserIterator iterator; !iterator.done(); iterator.Next())
++count;
return count;
}
}
TEST_F(BrowserIteratorTest, BrowsersOnMultipleDesktops) {
Browser::CreateParams native_params(profile(),
chrome::HOST_DESKTOP_TYPE_NATIVE);
Browser::CreateParams ash_params(profile(), chrome::HOST_DESKTOP_TYPE_ASH);
scoped_ptr<Browser> browser2(
chrome::CreateBrowserWithTestWindowForParams(&native_params));
scoped_ptr<Browser> browser3(
chrome::CreateBrowserWithTestWindowForParams(&native_params));
scoped_ptr<Browser> browser4(
chrome::CreateBrowserWithTestWindowForParams(&ash_params));
scoped_ptr<Browser> browser5(
chrome::CreateBrowserWithTestWindowForParams(&ash_params));
BrowserList* native_list =
BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE);
#if defined(OS_CHROMEOS)
EXPECT_EQ(5U, native_list->size());
#else
BrowserList* ash_list =
BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH);
EXPECT_EQ(3U, native_list->size());
EXPECT_EQ(2U, ash_list->size());
#endif
EXPECT_EQ(5U, CountAllBrowsers());
}
TEST_F(BrowserIteratorTest, NoBrowsersOnAshDesktop) {
Browser::CreateParams native_params(profile(),
chrome::HOST_DESKTOP_TYPE_NATIVE);
scoped_ptr<Browser> browser2(
chrome::CreateBrowserWithTestWindowForParams(&native_params));
scoped_ptr<Browser> browser3(
chrome::CreateBrowserWithTestWindowForParams(&native_params));
BrowserList* native_list =
BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE);
EXPECT_EQ(3U, native_list->size());
#if !defined(OS_CHROMEOS)
BrowserList* ash_list =
BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH);
EXPECT_EQ(0U, ash_list->size());
#endif
EXPECT_EQ(3U, CountAllBrowsers());
}
TEST_F(BrowserIteratorTestWithInitialWindowInAsh, NoBrowsersOnNativeDesktop) {
Browser::CreateParams ash_params(profile(), chrome::HOST_DESKTOP_TYPE_ASH);
scoped_ptr<Browser> browser2(
chrome::CreateBrowserWithTestWindowForParams(&ash_params));
scoped_ptr<Browser> browser3(
chrome::CreateBrowserWithTestWindowForParams(&ash_params));
BrowserList* ash_list =
BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH);
EXPECT_EQ(3U, ash_list->size());
#if !defined(OS_CHROMEOS)
BrowserList* native_list =
BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE);
EXPECT_EQ(0U, native_list->size());
#endif
EXPECT_EQ(3U, CountAllBrowsers());
}
TEST(BrowserIteratorTestWithNoTestWindow, NoBrowser) {
EXPECT_EQ(0U, CountAllBrowsers());
}