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

Side by Side Diff: chrome/browser/ui/browser_iterator_unittest.cc

Issue 1198313003: Fix the browser match rules. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use scoped_ptr<Browser> instead. Created 5 years, 5 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/browser_iterator.h" 5 #include "chrome/browser/ui/browser_iterator.h"
6 6
7 #include "chrome/browser/ui/browser.h" 7 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/browser_list.h" 8 #include "chrome/browser/ui/browser_list.h"
9 #include "chrome/browser/ui/host_desktop.h" 9 #include "chrome/browser/ui/host_desktop.h"
10 #include "chrome/test/base/browser_with_test_window_test.h" 10 #include "chrome/test/base/browser_with_test_window_test.h"
(...skipping 16 matching lines...) Expand all
27 }; 27 };
28 28
29 // Helper function to iterate and count all the browsers. 29 // Helper function to iterate and count all the browsers.
30 size_t CountAllBrowsers() { 30 size_t CountAllBrowsers() {
31 size_t count = 0; 31 size_t count = 0;
32 for (chrome::BrowserIterator iterator; !iterator.done(); iterator.Next()) 32 for (chrome::BrowserIterator iterator; !iterator.done(); iterator.Next())
33 ++count; 33 ++count;
34 return count; 34 return count;
35 } 35 }
36 36
37 } 37 } // namespace
38 38
39 TEST_F(BrowserIteratorTest, BrowsersOnMultipleDesktops) { 39 TEST_F(BrowserIteratorTest, BrowsersOnMultipleDesktops) {
40 Browser::CreateParams native_params(profile(), 40 Browser::CreateParams native_params(profile(),
41 chrome::HOST_DESKTOP_TYPE_NATIVE); 41 chrome::HOST_DESKTOP_TYPE_NATIVE);
42 Browser::CreateParams ash_params(profile(), chrome::HOST_DESKTOP_TYPE_ASH); 42 Browser::CreateParams ash_params(profile(), chrome::HOST_DESKTOP_TYPE_ASH);
43 // Note, browser 1 is on the native desktop. 43 // Note, browser 1 is on the native desktop.
44 scoped_ptr<Browser> browser2( 44 scoped_ptr<Browser> browser2 =
45 chrome::CreateBrowserWithTestWindowForParams(&native_params)); 45 chrome::CreateBrowserWithTestWindowForParams(&native_params);
46 scoped_ptr<Browser> browser3( 46 scoped_ptr<Browser> browser3 =
47 chrome::CreateBrowserWithTestWindowForParams(&native_params)); 47 chrome::CreateBrowserWithTestWindowForParams(&native_params);
48 scoped_ptr<Browser> browser4( 48 scoped_ptr<Browser> browser4 =
49 chrome::CreateBrowserWithTestWindowForParams(&ash_params)); 49 chrome::CreateBrowserWithTestWindowForParams(&ash_params);
50 scoped_ptr<Browser> browser5( 50 scoped_ptr<Browser> browser5 =
51 chrome::CreateBrowserWithTestWindowForParams(&ash_params)); 51 chrome::CreateBrowserWithTestWindowForParams(&ash_params);
52 52
53 // Sanity checks. 53 // Sanity checks.
54 BrowserList* native_list = 54 BrowserList* native_list =
55 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE); 55 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE);
56 #if defined(OS_CHROMEOS) 56 #if defined(OS_CHROMEOS)
57 // On Chrome OS, the native list and the ash list are the same. 57 // On Chrome OS, the native list and the ash list are the same.
58 EXPECT_EQ(5U, native_list->size()); 58 EXPECT_EQ(5U, native_list->size());
59 #else 59 #else
60 BrowserList* ash_list = 60 BrowserList* ash_list =
61 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); 61 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 115
116 // Make sure the iterator finds all 3 browsers on the ash desktop and 116 // Make sure the iterator finds all 3 browsers on the ash desktop and
117 // doesn't trip over the empty native desktop list. 117 // doesn't trip over the empty native desktop list.
118 EXPECT_EQ(3U, CountAllBrowsers()); 118 EXPECT_EQ(3U, CountAllBrowsers());
119 } 119 }
120 120
121 // Verify that the iterator still behaves if there are no browsers at all. 121 // Verify that the iterator still behaves if there are no browsers at all.
122 TEST(BrowserIteratorTestWithNoTestWindow, NoBrowser) { 122 TEST(BrowserIteratorTestWithNoTestWindow, NoBrowser) {
123 EXPECT_EQ(0U, CountAllBrowsers()); 123 EXPECT_EQ(0U, CountAllBrowsers());
124 } 124 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698