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 | 5 |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 23 matching lines...) Expand all Loading... | |
34 #include "extensions/common/test_util.h" | 34 #include "extensions/common/test_util.h" |
35 #include "net/test/spawned_test_server/spawned_test_server.h" | 35 #include "net/test/spawned_test_server/spawned_test_server.h" |
36 #include "ui/gfx/geometry/rect.h" | 36 #include "ui/gfx/geometry/rect.h" |
37 | 37 |
38 namespace extensions { | 38 namespace extensions { |
39 | 39 |
40 namespace keys = tabs_constants; | 40 namespace keys = tabs_constants; |
41 namespace utils = extension_function_test_utils; | 41 namespace utils = extension_function_test_utils; |
42 | 42 |
43 namespace { | 43 namespace { |
44 | 44 using ExtensionTabsTest = InProcessBrowserTest; |
45 class ExtensionTabsTest : public InProcessBrowserTest { | 45 using ExtensionWindowCreateTest = InProcessBrowserTest; |
46 }; | |
47 | |
48 } | 46 } |
49 | 47 |
50 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetWindow) { | 48 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetWindow) { |
51 int window_id = ExtensionTabUtil::GetWindowId(browser()); | 49 int window_id = ExtensionTabUtil::GetWindowId(browser()); |
52 | 50 |
53 // Invalid window ID error. | 51 // Invalid window ID error. |
54 scoped_refptr<WindowsGetFunction> function = new WindowsGetFunction(); | 52 scoped_refptr<WindowsGetFunction> function = new WindowsGetFunction(); |
55 scoped_refptr<Extension> extension(test_util::CreateEmptyExtension()); | 53 scoped_refptr<Extension> extension(test_util::CreateEmptyExtension()); |
56 function->set_extension(extension.get()); | 54 function->set_extension(extension.get()); |
57 EXPECT_TRUE(MatchPattern( | 55 EXPECT_TRUE(MatchPattern( |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
557 function = new WindowsUpdateFunction(); | 555 function = new WindowsUpdateFunction(); |
558 function->set_extension(extension.get()); | 556 function->set_extension(extension.get()); |
559 EXPECT_TRUE(MatchPattern( | 557 EXPECT_TRUE(MatchPattern( |
560 utils::RunFunctionAndReturnError( | 558 utils::RunFunctionAndReturnError( |
561 function.get(), | 559 function.get(), |
562 base::StringPrintf(kArgsMaximizedWithBounds, window_id), | 560 base::StringPrintf(kArgsMaximizedWithBounds, window_id), |
563 browser()), | 561 browser()), |
564 keys::kInvalidWindowStateError)); | 562 keys::kInvalidWindowStateError)); |
565 } | 563 } |
566 | 564 |
565 IN_PROC_BROWSER_TEST_F(ExtensionWindowCreateTest, AcceptState) { | |
566 scoped_refptr<WindowsCreateFunction> function(new WindowsCreateFunction()); | |
567 scoped_refptr<Extension> extension(test_util::CreateEmptyExtension()); | |
568 function->set_extension(extension.get()); | |
569 | |
570 scoped_ptr<base::DictionaryValue> result( | |
571 utils::ToDictionary(utils::RunFunctionAndReturnSingleResult( | |
572 function.get(), "[{\"state\": \"fullscreen\"}]", browser(), | |
573 utils::INCLUDE_INCOGNITO))); | |
574 int window_id = api_test_utils::GetInteger(result.get(), "id"); | |
575 std::string error; | |
576 Browser* new_window = ExtensionTabUtil::GetBrowserFromWindowID( | |
577 function.get(), window_id, &error); | |
578 EXPECT_TRUE(new_window->window()->IsFullscreen()); | |
579 EXPECT_TRUE(error.empty()); | |
580 | |
581 function = new WindowsCreateFunction(); | |
582 function->set_extension(extension.get()); | |
583 result.reset(utils::ToDictionary(utils::RunFunctionAndReturnSingleResult( | |
584 function.get(), "[{\"state\": \"minimized\"}]", browser(), | |
585 utils::INCLUDE_INCOGNITO))); | |
586 window_id = api_test_utils::GetInteger(result.get(), "id"); | |
587 new_window = ExtensionTabUtil::GetBrowserFromWindowID(function.get(), | |
588 window_id, &error); | |
589 EXPECT_TRUE(error.empty()); | |
590 #if !defined(OS_LINUX) || defined(OS_CHROMEOS) | |
not at google - send to devlin
2015/04/17 16:49:47
does defined(OS_CHROMEOS) not already imply !defin
limasdf
2015/04/17 18:33:26
This #if guard should NOT enabled for only 'Linux
| |
591 // DesktopWindowTreeHostX11::IsMinimized() relies on an asynchronous update | |
592 // from the window server. | |
593 EXPECT_TRUE(new_window->window()->IsMinimized()); | |
594 #endif | |
595 } | |
596 | |
567 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DuplicateTab) { | 597 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DuplicateTab) { |
568 content::OpenURLParams params(GURL(url::kAboutBlankURL), | 598 content::OpenURLParams params(GURL(url::kAboutBlankURL), |
569 content::Referrer(), | 599 content::Referrer(), |
570 NEW_FOREGROUND_TAB, | 600 NEW_FOREGROUND_TAB, |
571 ui::PAGE_TRANSITION_LINK, | 601 ui::PAGE_TRANSITION_LINK, |
572 false); | 602 false); |
573 content::WebContents* web_contents = browser()->OpenURL(params); | 603 content::WebContents* web_contents = browser()->OpenURL(params); |
574 int tab_id = ExtensionTabUtil::GetTabId(web_contents); | 604 int tab_id = ExtensionTabUtil::GetTabId(web_contents); |
575 int window_id = ExtensionTabUtil::GetWindowIdOfTab(web_contents); | 605 int window_id = ExtensionTabUtil::GetWindowIdOfTab(web_contents); |
576 int tab_index = -1; | 606 int tab_index = -1; |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1085 // Test chrome.tabs.setZoom(). | 1115 // Test chrome.tabs.setZoom(). |
1086 error = RunSetZoomExpectError(tab_id, 3.14159); | 1116 error = RunSetZoomExpectError(tab_id, 3.14159); |
1087 EXPECT_TRUE(MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); | 1117 EXPECT_TRUE(MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); |
1088 | 1118 |
1089 // chrome.tabs.setZoomSettings(). | 1119 // chrome.tabs.setZoomSettings(). |
1090 error = RunSetZoomSettingsExpectError(tab_id, "manual", "per-tab"); | 1120 error = RunSetZoomSettingsExpectError(tab_id, "manual", "per-tab"); |
1091 EXPECT_TRUE(MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); | 1121 EXPECT_TRUE(MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); |
1092 } | 1122 } |
1093 | 1123 |
1094 } // namespace extensions | 1124 } // namespace extensions |
OLD | NEW |