OLD | NEW |
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 #include <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "chrome/common/automation_constants.h" | 9 #include "chrome/common/automation_constants.h" |
10 #include "chrome/common/automation_messages.h" | 10 #include "chrome/common/automation_messages.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 std::vector<int> port_counts_; | 65 std::vector<int> port_counts_; |
66 }; | 66 }; |
67 | 67 |
68 TEST_F(MachPortsTest, GetCounts) { | 68 TEST_F(MachPortsTest, GetCounts) { |
69 ASSERT_EQ(AUTOMATION_SUCCESS, automation()->WaitForAppLaunch()); | 69 ASSERT_EQ(AUTOMATION_SUCCESS, automation()->WaitForAppLaunch()); |
70 | 70 |
71 // Record startup number. | 71 // Record startup number. |
72 RecordPortCount(); | 72 RecordPortCount(); |
73 | 73 |
74 // Create a browser and open a few tabs. | 74 // Create a browser and open a few tabs. |
75 scoped_refptr<BrowserProxy> browser(automation()->FindTabbedBrowserWindow()); | 75 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
76 ASSERT_TRUE(browser.get()); | 76 ASSERT_TRUE(browser.get()); |
77 | 77 |
78 EXPECT_TRUE(AddTab(browser, "www.google.com")); | 78 EXPECT_TRUE(AddTab(browser, "www.google.com")); |
79 RecordPortCount(); | 79 RecordPortCount(); |
80 | 80 |
81 EXPECT_TRUE(AddTab(browser, "www.cnn.com")); | 81 EXPECT_TRUE(AddTab(browser, "www.cnn.com")); |
82 RecordPortCount(); | 82 RecordPortCount(); |
83 | 83 |
84 EXPECT_TRUE(AddTab(browser, "www.nytimes.com")); | 84 EXPECT_TRUE(AddTab(browser, "www.nytimes.com")); |
85 RecordPortCount(); | 85 RecordPortCount(); |
86 | 86 |
87 int tab_count = 0; | 87 int tab_count = 0; |
88 ASSERT_TRUE(browser->GetTabCount(&tab_count)); | 88 ASSERT_TRUE(browser->GetTabCount(&tab_count)); |
89 EXPECT_EQ(4, tab_count); // Also count about:blank. | 89 EXPECT_EQ(4, tab_count); // Also count about:blank. |
90 | 90 |
91 // Close each tab, recording the number of ports after each. Do not close the | 91 // Close each tab, recording the number of ports after each. Do not close the |
92 // last tab, which is about:blank because it will be closed by the proxy. | 92 // last tab, which is about:blank because it will be closed by the proxy. |
93 for (int i = 0; i < tab_count - 1; ++i) { | 93 for (int i = 0; i < tab_count - 1; ++i) { |
94 scoped_refptr<TabProxy> tab(browser->GetActiveTab()); | 94 scoped_refptr<TabProxy> tab(browser->GetActiveTab()); |
95 ASSERT_TRUE(tab.get()); | 95 ASSERT_TRUE(tab.get()); |
96 | 96 |
97 EXPECT_TRUE(tab->Close(true)); | 97 EXPECT_TRUE(tab->Close(true)); |
98 RecordPortCount(); | 98 RecordPortCount(); |
99 } | 99 } |
100 } | 100 } |
101 | 101 |
102 } // namespace | 102 } // namespace |
OLD | NEW |