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

Side by Side Diff: chrome/browser/app_controller_mac_browsertest.mm

Issue 12213075: Swap deprecated BrowserList:: iterators for BrowserIterator in non-Windows code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge up to r181832 Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/app_controller_mac.mm ('k') | chrome/browser/chromeos/boot_times_loader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/scoped_nsobject.h" 8 #include "base/memory/scoped_nsobject.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #import "chrome/browser/app_controller_mac.h" 10 #import "chrome/browser/app_controller_mac.h"
11 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/browser_list.h" 12 #include "chrome/browser/ui/browser_list.h"
13 #include "chrome/browser/ui/browser_list_impl.h"
14 #include "chrome/browser/ui/host_desktop.h"
13 #include "chrome/browser/ui/tabs/tab_strip_model.h" 15 #include "chrome/browser/ui/tabs/tab_strip_model.h"
14 #import "chrome/common/chrome_switches.h" 16 #import "chrome/common/chrome_switches.h"
15 #include "chrome/test/base/in_process_browser_test.h" 17 #include "chrome/test/base/in_process_browser_test.h"
16 #include "chrome/test/base/ui_test_utils.h" 18 #include "chrome/test/base/ui_test_utils.h"
17 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
18 20
19 namespace { 21 namespace {
20 22
21 class AppControllerPlatformAppBrowserTest : public InProcessBrowserTest { 23 class AppControllerPlatformAppBrowserTest : public InProcessBrowserTest {
22 protected: 24 protected:
23 AppControllerPlatformAppBrowserTest() {} 25 AppControllerPlatformAppBrowserTest()
26 : native_browser_list(chrome::BrowserListImpl::GetInstance(
27 chrome::HOST_DESKTOP_TYPE_NATIVE)) {
28 }
24 29
25 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 30 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
26 command_line->AppendSwitchASCII(switches::kAppId, 31 command_line->AppendSwitchASCII(switches::kAppId,
27 "1234"); 32 "1234");
28 } 33 }
34
35 // Mac only has the native desktop.
36 const chrome::BrowserListImpl* native_browser_list;
29 }; 37 };
30 38
31 // Test that if only a platform app window is open and no browser windows are 39 // Test that if only a platform app window is open and no browser windows are
32 // open then a reopen event does nothing. 40 // open then a reopen event does nothing.
33 IN_PROC_BROWSER_TEST_F(AppControllerPlatformAppBrowserTest, 41 IN_PROC_BROWSER_TEST_F(AppControllerPlatformAppBrowserTest,
34 PlatformAppReopenWithWindows) { 42 PlatformAppReopenWithWindows) {
35 scoped_nsobject<AppController> ac([[AppController alloc] init]); 43 scoped_nsobject<AppController> ac([[AppController alloc] init]);
36 NSUInteger old_window_count = [[NSApp windows] count]; 44 NSUInteger old_window_count = [[NSApp windows] count];
37 EXPECT_EQ(1u, BrowserList::size()); 45 EXPECT_EQ(1u, native_browser_list->size());
38 BOOL result = [ac applicationShouldHandleReopen:NSApp hasVisibleWindows:YES]; 46 BOOL result = [ac applicationShouldHandleReopen:NSApp hasVisibleWindows:YES];
39 47
40 EXPECT_TRUE(result); 48 EXPECT_TRUE(result);
41 EXPECT_EQ(old_window_count, [[NSApp windows] count]); 49 EXPECT_EQ(old_window_count, [[NSApp windows] count]);
42 EXPECT_EQ(1u, BrowserList::size()); 50 EXPECT_EQ(1u, native_browser_list->size());
43 } 51 }
44 52
45 class AppControllerWebAppBrowserTest : public InProcessBrowserTest { 53 class AppControllerWebAppBrowserTest : public InProcessBrowserTest {
46 protected: 54 protected:
47 AppControllerWebAppBrowserTest() {} 55 AppControllerWebAppBrowserTest()
56 : native_browser_list(chrome::BrowserListImpl::GetInstance(
57 chrome::HOST_DESKTOP_TYPE_NATIVE)) {
58 }
48 59
49 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 60 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
50 command_line->AppendSwitchASCII(switches::kApp, GetAppURL()); 61 command_line->AppendSwitchASCII(switches::kApp, GetAppURL());
51 } 62 }
52 63
53 std::string GetAppURL() const { 64 std::string GetAppURL() const {
54 return "http://example.com/"; 65 return "http://example.com/";
55 } 66 }
67
68 // Mac only has the native desktop.
69 const chrome::BrowserListImpl* native_browser_list;
56 }; 70 };
57 71
58 // Test that in web app mode a reopen event opens the app URL. 72 // Test that in web app mode a reopen event opens the app URL.
59 IN_PROC_BROWSER_TEST_F(AppControllerWebAppBrowserTest, 73 IN_PROC_BROWSER_TEST_F(AppControllerWebAppBrowserTest,
60 WebAppReopenWithNoWindows) { 74 WebAppReopenWithNoWindows) {
61 scoped_nsobject<AppController> ac([[AppController alloc] init]); 75 scoped_nsobject<AppController> ac([[AppController alloc] init]);
62 EXPECT_EQ(1u, BrowserList::size()); 76 EXPECT_EQ(1u, native_browser_list->size());
63 BOOL result = [ac applicationShouldHandleReopen:NSApp hasVisibleWindows:NO]; 77 BOOL result = [ac applicationShouldHandleReopen:NSApp hasVisibleWindows:NO];
64 78
65 EXPECT_FALSE(result); 79 EXPECT_FALSE(result);
66 EXPECT_EQ(2u, BrowserList::size()); 80 EXPECT_EQ(2u, native_browser_list->size());
67 81
68 Browser* browser = *(BrowserList::begin()); 82 Browser* browser = native_browser_list->get(0);
69 GURL current_url = 83 GURL current_url =
70 browser->tab_strip_model()->GetActiveWebContents()->GetURL(); 84 browser->tab_strip_model()->GetActiveWebContents()->GetURL();
71 EXPECT_EQ(GetAppURL(), current_url.spec()); 85 EXPECT_EQ(GetAppURL(), current_url.spec());
72 } 86 }
73 87
74 } // namespace 88 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/app_controller_mac.mm ('k') | chrome/browser/chromeos/boot_times_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698