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 24 matching lines...) Expand all Loading... | |
35 namespace extensions { | 35 namespace extensions { |
36 | 36 |
37 namespace keys = tabs_constants; | 37 namespace keys = tabs_constants; |
38 namespace utils = extension_function_test_utils; | 38 namespace utils = extension_function_test_utils; |
39 | 39 |
40 namespace { | 40 namespace { |
41 | 41 |
42 class ExtensionTabsTest : public InProcessBrowserTest { | 42 class ExtensionTabsTest : public InProcessBrowserTest { |
43 }; | 43 }; |
44 | 44 |
45 class ExtensionWindowCreateTest : public InProcessBrowserTest { | |
46 public: | |
47 void SetUpOnMainThread() override; | |
48 | |
49 // Run chrome.windows.create(). If success, return |true|. | |
50 bool RunCreateWindow(const std::string& args); | |
51 | |
52 private: | |
53 scoped_refptr<Extension> extension_; | |
54 }; | |
55 | |
56 void ExtensionWindowCreateTest::SetUpOnMainThread() { | |
57 extension_ = test_util::CreateEmptyExtension(); | |
45 } | 58 } |
46 | 59 |
60 bool ExtensionWindowCreateTest::RunCreateWindow(const std::string& args) { | |
61 scoped_refptr<WindowsCreateFunction> function(new WindowsCreateFunction()); | |
62 function->set_extension(extension_.get()); | |
63 return extensions::api_test_utils::RunFunction(function.get(), args, | |
64 browser()->profile()); | |
65 } | |
66 | |
67 } // namespace | |
68 | |
47 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetWindow) { | 69 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetWindow) { |
48 int window_id = ExtensionTabUtil::GetWindowId(browser()); | 70 int window_id = ExtensionTabUtil::GetWindowId(browser()); |
49 | 71 |
50 // Invalid window ID error. | 72 // Invalid window ID error. |
51 scoped_refptr<WindowsGetFunction> function = new WindowsGetFunction(); | 73 scoped_refptr<WindowsGetFunction> function = new WindowsGetFunction(); |
52 scoped_refptr<Extension> extension(test_util::CreateEmptyExtension()); | 74 scoped_refptr<Extension> extension(test_util::CreateEmptyExtension()); |
53 function->set_extension(extension.get()); | 75 function->set_extension(extension.get()); |
54 EXPECT_TRUE(MatchPattern( | 76 EXPECT_TRUE(MatchPattern( |
55 utils::RunFunctionAndReturnError( | 77 utils::RunFunctionAndReturnError( |
56 function.get(), | 78 function.get(), |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
554 function = new WindowsUpdateFunction(); | 576 function = new WindowsUpdateFunction(); |
555 function->set_extension(extension.get()); | 577 function->set_extension(extension.get()); |
556 EXPECT_TRUE(MatchPattern( | 578 EXPECT_TRUE(MatchPattern( |
557 utils::RunFunctionAndReturnError( | 579 utils::RunFunctionAndReturnError( |
558 function.get(), | 580 function.get(), |
559 base::StringPrintf(kArgsMaximizedWithBounds, window_id), | 581 base::StringPrintf(kArgsMaximizedWithBounds, window_id), |
560 browser()), | 582 browser()), |
561 keys::kInvalidWindowStateError)); | 583 keys::kInvalidWindowStateError)); |
562 } | 584 } |
563 | 585 |
586 IN_PROC_BROWSER_TEST_F(ExtensionWindowCreateTest, ValidateCreateWindowState) { | |
587 EXPECT_TRUE(RunCreateWindow("[{\"state\": \"fullscreen\"}]")); | |
not at google - send to devlin
2015/03/19 17:56:31
What is this testing?
If anything I would have th
limasdf
2015/03/20 17:03:46
Done. But fullscreen test is added only. It looks
| |
588 EXPECT_TRUE(RunCreateWindow("[{\"state\": \"maximized\"}]")); | |
589 EXPECT_TRUE(RunCreateWindow("[{\"state\": \"minimized\"}]")); | |
590 EXPECT_TRUE(RunCreateWindow("[{\"state\": \"normal\"}]")); | |
591 } | |
592 | |
564 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DuplicateTab) { | 593 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DuplicateTab) { |
565 content::OpenURLParams params(GURL(url::kAboutBlankURL), | 594 content::OpenURLParams params(GURL(url::kAboutBlankURL), |
566 content::Referrer(), | 595 content::Referrer(), |
567 NEW_FOREGROUND_TAB, | 596 NEW_FOREGROUND_TAB, |
568 ui::PAGE_TRANSITION_LINK, | 597 ui::PAGE_TRANSITION_LINK, |
569 false); | 598 false); |
570 content::WebContents* web_contents = browser()->OpenURL(params); | 599 content::WebContents* web_contents = browser()->OpenURL(params); |
571 int tab_id = ExtensionTabUtil::GetTabId(web_contents); | 600 int tab_id = ExtensionTabUtil::GetTabId(web_contents); |
572 int window_id = ExtensionTabUtil::GetWindowIdOfTab(web_contents); | 601 int window_id = ExtensionTabUtil::GetWindowIdOfTab(web_contents); |
573 int tab_index = -1; | 602 int tab_index = -1; |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
994 // Test chrome.tabs.setZoom(). | 1023 // Test chrome.tabs.setZoom(). |
995 error = RunSetZoomExpectError(tab_id, 3.14159); | 1024 error = RunSetZoomExpectError(tab_id, 3.14159); |
996 EXPECT_TRUE(MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); | 1025 EXPECT_TRUE(MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); |
997 | 1026 |
998 // chrome.tabs.setZoomSettings(). | 1027 // chrome.tabs.setZoomSettings(). |
999 error = RunSetZoomSettingsExpectError(tab_id, "manual", "per-tab"); | 1028 error = RunSetZoomSettingsExpectError(tab_id, "manual", "per-tab"); |
1000 EXPECT_TRUE(MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); | 1029 EXPECT_TRUE(MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); |
1001 } | 1030 } |
1002 | 1031 |
1003 } // namespace extensions | 1032 } // namespace extensions |
OLD | NEW |