| 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 "chrome/browser/extensions/api/tabs/tabs.h" | 5 #include "chrome/browser/extensions/api/tabs/tabs.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 14 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
| 15 #include "chrome/browser/extensions/extension_function_test_utils.h" | 15 #include "chrome/browser/extensions/extension_function_test_utils.h" |
| 16 #include "chrome/browser/extensions/extension_tab_util.h" | 16 #include "chrome/browser/extensions/extension_tab_util.h" |
| 17 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 17 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 18 #include "chrome/browser/prefs/pref_service.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/browser/ui/browser_commands.h" | 21 #include "chrome/browser/ui/browser_commands.h" |
| 21 #include "chrome/browser/ui/browser_window.h" | 22 #include "chrome/browser/ui/browser_window.h" |
| 22 #include "chrome/test/base/in_process_browser_test.h" | 23 #include "chrome/test/base/in_process_browser_test.h" |
| 23 #include "chrome/test/base/ui_test_utils.h" | 24 #include "chrome/test/base/ui_test_utils.h" |
| 24 #include "ui/gfx/rect.h" | 25 #include "ui/gfx/rect.h" |
| 25 | 26 |
| 26 namespace keys = extensions::tabs_constants; | 27 namespace keys = extensions::tabs_constants; |
| 27 namespace utils = extension_function_test_utils; | 28 namespace utils = extension_function_test_utils; |
| 28 | 29 |
| 29 namespace { | 30 namespace { |
| 30 | 31 |
| 31 class ExtensionTabsTest : public InProcessBrowserTest { | 32 class ExtensionTabsTest : public InProcessBrowserTest { |
| 32 }; | 33 }; |
| 34 |
| 33 } | 35 } |
| 34 | 36 |
| 35 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetWindow) { | 37 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetWindow) { |
| 36 int window_id = ExtensionTabUtil::GetWindowId(browser()); | 38 int window_id = ExtensionTabUtil::GetWindowId(browser()); |
| 37 | 39 |
| 38 // Invalid window ID error. | 40 // Invalid window ID error. |
| 39 scoped_refptr<GetWindowFunction> function = new GetWindowFunction(); | 41 scoped_refptr<GetWindowFunction> function = new GetWindowFunction(); |
| 40 scoped_refptr<extensions::Extension> extension(utils::CreateEmptyExtension()); | 42 scoped_refptr<extensions::Extension> extension(utils::CreateEmptyExtension()); |
| 41 function->set_extension(extension.get()); | 43 function->set_extension(extension.get()); |
| 42 EXPECT_TRUE(MatchPattern( | 44 EXPECT_TRUE(MatchPattern( |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 int duplicate_tab_index = utils::GetInteger(duplicate_result.get(), "index"); | 591 int duplicate_tab_index = utils::GetInteger(duplicate_result.get(), "index"); |
| 590 EXPECT_EQ(base::Value::TYPE_DICTIONARY, duplicate_result->GetType()); | 592 EXPECT_EQ(base::Value::TYPE_DICTIONARY, duplicate_result->GetType()); |
| 591 // Duplicate tab id should be different from the original tab id. | 593 // Duplicate tab id should be different from the original tab id. |
| 592 EXPECT_NE(tab_id, duplicate_tab_id); | 594 EXPECT_NE(tab_id, duplicate_tab_id); |
| 593 EXPECT_EQ(window_id, duplicate_tab_window_id); | 595 EXPECT_EQ(window_id, duplicate_tab_window_id); |
| 594 EXPECT_EQ(tab_index + 1, duplicate_tab_index); | 596 EXPECT_EQ(tab_index + 1, duplicate_tab_index); |
| 595 // The test empty extension has no permissions, therefore |duplicate_result| | 597 // The test empty extension has no permissions, therefore |duplicate_result| |
| 596 // should not contain url, title, and faviconUrl in the function result. | 598 // should not contain url, title, and faviconUrl in the function result. |
| 597 EXPECT_FALSE(utils::HasPrivacySensitiveFields(duplicate_result.get())); | 599 EXPECT_FALSE(utils::HasPrivacySensitiveFields(duplicate_result.get())); |
| 598 } | 600 } |
| OLD | NEW |