| 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 <limits.h> | 5 #include <limits.h> |
| 6 #include <stddef.h> | 6 #include <stddef.h> |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 function->set_extension(extension.get()); | 146 function->set_extension(extension.get()); |
| 147 result.reset(utils::ToDictionary( | 147 result.reset(utils::ToDictionary( |
| 148 utils::RunFunctionAndReturnSingleResult( | 148 utils::RunFunctionAndReturnSingleResult( |
| 149 function.get(), | 149 function.get(), |
| 150 base::StringPrintf("[%u, {\"populate\": true}]", window_id), | 150 base::StringPrintf("[%u, {\"populate\": true}]", window_id), |
| 151 browser()))); | 151 browser()))); |
| 152 | 152 |
| 153 EXPECT_EQ(window_id, GetWindowId(result.get())); | 153 EXPECT_EQ(window_id, GetWindowId(result.get())); |
| 154 // "populate" was enabled so tabs should be populated. | 154 // "populate" was enabled so tabs should be populated. |
| 155 base::ListValue* tabs = nullptr; | 155 base::ListValue* tabs = nullptr; |
| 156 EXPECT_TRUE(result.get()->GetList(keys::kTabsKey, &tabs)); | 156 EXPECT_TRUE(result->GetList(keys::kTabsKey, &tabs)); |
| 157 | 157 |
| 158 base::Value* tab0 = nullptr; | 158 base::Value* tab0 = nullptr; |
| 159 EXPECT_TRUE(tabs->Get(0, &tab0)); | 159 EXPECT_TRUE(tabs->Get(0, &tab0)); |
| 160 EXPECT_GE(GetTabId(utils::ToDictionary(tab0)), 0); | 160 EXPECT_GE(GetTabId(utils::ToDictionary(tab0)), 0); |
| 161 | 161 |
| 162 // TODO(aa): Can't assume window is focused. On mac, calling Activate() from a | 162 // TODO(aa): Can't assume window is focused. On mac, calling Activate() from a |
| 163 // browser test doesn't seem to do anything, so can't test the opposite | 163 // browser test doesn't seem to do anything, so can't test the opposite |
| 164 // either. | 164 // either. |
| 165 EXPECT_EQ(browser()->window()->IsActive(), | 165 EXPECT_EQ(browser()->window()->IsActive(), |
| 166 api_test_utils::GetBoolean(result.get(), "focused")); | 166 api_test_utils::GetBoolean(result.get(), "focused")); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 scoped_refptr<Extension> extension(test_util::CreateEmptyExtension()); | 233 scoped_refptr<Extension> extension(test_util::CreateEmptyExtension()); |
| 234 function->set_extension(extension.get()); | 234 function->set_extension(extension.get()); |
| 235 std::unique_ptr<base::DictionaryValue> result( | 235 std::unique_ptr<base::DictionaryValue> result( |
| 236 utils::ToDictionary(utils::RunFunctionAndReturnSingleResult( | 236 utils::ToDictionary(utils::RunFunctionAndReturnSingleResult( |
| 237 function.get(), "[]", new_browser))); | 237 function.get(), "[]", new_browser))); |
| 238 | 238 |
| 239 // The id should match the window id of the browser instance that was passed | 239 // The id should match the window id of the browser instance that was passed |
| 240 // to RunFunctionAndReturnSingleResult. | 240 // to RunFunctionAndReturnSingleResult. |
| 241 EXPECT_EQ(new_id, GetWindowId(result.get())); | 241 EXPECT_EQ(new_id, GetWindowId(result.get())); |
| 242 base::ListValue* tabs = nullptr; | 242 base::ListValue* tabs = nullptr; |
| 243 EXPECT_FALSE(result.get()->GetList(keys::kTabsKey, &tabs)); | 243 EXPECT_FALSE(result->GetList(keys::kTabsKey, &tabs)); |
| 244 | 244 |
| 245 // Get the current window using the old window and make the tabs populated. | 245 // Get the current window using the old window and make the tabs populated. |
| 246 function = new WindowsGetCurrentFunction(); | 246 function = new WindowsGetCurrentFunction(); |
| 247 function->set_extension(extension.get()); | 247 function->set_extension(extension.get()); |
| 248 result.reset(utils::ToDictionary( | 248 result.reset(utils::ToDictionary( |
| 249 utils::RunFunctionAndReturnSingleResult(function.get(), | 249 utils::RunFunctionAndReturnSingleResult(function.get(), |
| 250 "[{\"populate\": true}]", | 250 "[{\"populate\": true}]", |
| 251 browser()))); | 251 browser()))); |
| 252 | 252 |
| 253 // The id should match the window id of the browser instance that was passed | 253 // The id should match the window id of the browser instance that was passed |
| 254 // to RunFunctionAndReturnSingleResult. | 254 // to RunFunctionAndReturnSingleResult. |
| 255 EXPECT_EQ(window_id, GetWindowId(result.get())); | 255 EXPECT_EQ(window_id, GetWindowId(result.get())); |
| 256 // "populate" was enabled so tabs should be populated. | 256 // "populate" was enabled so tabs should be populated. |
| 257 EXPECT_TRUE(result.get()->GetList(keys::kTabsKey, &tabs)); | 257 EXPECT_TRUE(result->GetList(keys::kTabsKey, &tabs)); |
| 258 | 258 |
| 259 // The tab id should not be -1 as this is a browser window. | 259 // The tab id should not be -1 as this is a browser window. |
| 260 base::Value* tab0 = nullptr; | 260 base::Value* tab0 = nullptr; |
| 261 EXPECT_TRUE(tabs->Get(0, &tab0)); | 261 EXPECT_TRUE(tabs->Get(0, &tab0)); |
| 262 EXPECT_GE(GetTabId(utils::ToDictionary(tab0)), 0); | 262 EXPECT_GE(GetTabId(utils::ToDictionary(tab0)), 0); |
| 263 } | 263 } |
| 264 | 264 |
| 265 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetAllWindows) { | 265 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetAllWindows) { |
| 266 const size_t NUM_WINDOWS = 5; | 266 const size_t NUM_WINDOWS = 5; |
| 267 std::set<int> window_ids; | 267 std::set<int> window_ids; |
| (...skipping 1597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1865 EXPECT_TRUE( | 1865 EXPECT_TRUE( |
| 1866 base::MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); | 1866 base::MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); |
| 1867 | 1867 |
| 1868 // chrome.tabs.setZoomSettings(). | 1868 // chrome.tabs.setZoomSettings(). |
| 1869 error = RunSetZoomSettingsExpectError(tab_id, "manual", "per-tab"); | 1869 error = RunSetZoomSettingsExpectError(tab_id, "manual", "per-tab"); |
| 1870 EXPECT_TRUE( | 1870 EXPECT_TRUE( |
| 1871 base::MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); | 1871 base::MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); |
| 1872 } | 1872 } |
| 1873 | 1873 |
| 1874 } // namespace extensions | 1874 } // namespace extensions |
| OLD | NEW |