Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: chrome/browser/extensions/api/tabs/tabs_test.cc

Issue 1015123003: Extension window.create API accepts state. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minimize(), Maximize() after Show() Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 {};
tapted 2015/03/22 23:05:18 I think the preferred way to do this now is using
45 } 46 }
46 47
47 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetWindow) { 48 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetWindow) {
48 int window_id = ExtensionTabUtil::GetWindowId(browser()); 49 int window_id = ExtensionTabUtil::GetWindowId(browser());
49 50
50 // Invalid window ID error. 51 // Invalid window ID error.
51 scoped_refptr<WindowsGetFunction> function = new WindowsGetFunction(); 52 scoped_refptr<WindowsGetFunction> function = new WindowsGetFunction();
52 scoped_refptr<Extension> extension(test_util::CreateEmptyExtension()); 53 scoped_refptr<Extension> extension(test_util::CreateEmptyExtension());
53 function->set_extension(extension.get()); 54 function->set_extension(extension.get());
54 EXPECT_TRUE(MatchPattern( 55 EXPECT_TRUE(MatchPattern(
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 function = new WindowsUpdateFunction(); 555 function = new WindowsUpdateFunction();
555 function->set_extension(extension.get()); 556 function->set_extension(extension.get());
556 EXPECT_TRUE(MatchPattern( 557 EXPECT_TRUE(MatchPattern(
557 utils::RunFunctionAndReturnError( 558 utils::RunFunctionAndReturnError(
558 function.get(), 559 function.get(),
559 base::StringPrintf(kArgsMaximizedWithBounds, window_id), 560 base::StringPrintf(kArgsMaximizedWithBounds, window_id),
560 browser()), 561 browser()),
561 keys::kInvalidWindowStateError)); 562 keys::kInvalidWindowStateError));
562 } 563 }
563 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 }
580
564 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DuplicateTab) { 581 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DuplicateTab) {
565 content::OpenURLParams params(GURL(url::kAboutBlankURL), 582 content::OpenURLParams params(GURL(url::kAboutBlankURL),
566 content::Referrer(), 583 content::Referrer(),
567 NEW_FOREGROUND_TAB, 584 NEW_FOREGROUND_TAB,
568 ui::PAGE_TRANSITION_LINK, 585 ui::PAGE_TRANSITION_LINK,
569 false); 586 false);
570 content::WebContents* web_contents = browser()->OpenURL(params); 587 content::WebContents* web_contents = browser()->OpenURL(params);
571 int tab_id = ExtensionTabUtil::GetTabId(web_contents); 588 int tab_id = ExtensionTabUtil::GetTabId(web_contents);
572 int window_id = ExtensionTabUtil::GetWindowIdOfTab(web_contents); 589 int window_id = ExtensionTabUtil::GetWindowIdOfTab(web_contents);
573 int tab_index = -1; 590 int tab_index = -1;
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 // Test chrome.tabs.setZoom(). 1011 // Test chrome.tabs.setZoom().
995 error = RunSetZoomExpectError(tab_id, 3.14159); 1012 error = RunSetZoomExpectError(tab_id, 3.14159);
996 EXPECT_TRUE(MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); 1013 EXPECT_TRUE(MatchPattern(error, manifest_errors::kCannotAccessChromeUrl));
997 1014
998 // chrome.tabs.setZoomSettings(). 1015 // chrome.tabs.setZoomSettings().
999 error = RunSetZoomSettingsExpectError(tab_id, "manual", "per-tab"); 1016 error = RunSetZoomSettingsExpectError(tab_id, "manual", "per-tab");
1000 EXPECT_TRUE(MatchPattern(error, manifest_errors::kCannotAccessChromeUrl)); 1017 EXPECT_TRUE(MatchPattern(error, manifest_errors::kCannotAccessChromeUrl));
1001 } 1018 }
1002 1019
1003 } // namespace extensions 1020 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/tabs/tabs_api.cc ('k') | chrome/common/extensions/api/windows.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698