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

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: minimized test Created 5 years, 8 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 21 matching lines...) Expand all
32 #include "net/test/spawned_test_server/spawned_test_server.h" 32 #include "net/test/spawned_test_server/spawned_test_server.h"
33 #include "ui/gfx/geometry/rect.h" 33 #include "ui/gfx/geometry/rect.h"
34 34
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 using ExtensionTabsTest = InProcessBrowserTest;
43 }; 43 using ExtensionWindowCreateTest = InProcessBrowserTest;
44
45 } 44 }
46 45
47 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetWindow) { 46 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, GetWindow) {
48 int window_id = ExtensionTabUtil::GetWindowId(browser()); 47 int window_id = ExtensionTabUtil::GetWindowId(browser());
49 48
50 // Invalid window ID error. 49 // Invalid window ID error.
51 scoped_refptr<WindowsGetFunction> function = new WindowsGetFunction(); 50 scoped_refptr<WindowsGetFunction> function = new WindowsGetFunction();
52 scoped_refptr<Extension> extension(test_util::CreateEmptyExtension()); 51 scoped_refptr<Extension> extension(test_util::CreateEmptyExtension());
53 function->set_extension(extension.get()); 52 function->set_extension(extension.get());
54 EXPECT_TRUE(MatchPattern( 53 EXPECT_TRUE(MatchPattern(
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 function = new WindowsUpdateFunction(); 553 function = new WindowsUpdateFunction();
555 function->set_extension(extension.get()); 554 function->set_extension(extension.get());
556 EXPECT_TRUE(MatchPattern( 555 EXPECT_TRUE(MatchPattern(
557 utils::RunFunctionAndReturnError( 556 utils::RunFunctionAndReturnError(
558 function.get(), 557 function.get(),
559 base::StringPrintf(kArgsMaximizedWithBounds, window_id), 558 base::StringPrintf(kArgsMaximizedWithBounds, window_id),
560 browser()), 559 browser()),
561 keys::kInvalidWindowStateError)); 560 keys::kInvalidWindowStateError));
562 } 561 }
563 562
563 IN_PROC_BROWSER_TEST_F(ExtensionWindowCreateTest, AcceptState) {
564 scoped_refptr<WindowsCreateFunction> function(new WindowsCreateFunction());
565 scoped_refptr<Extension> extension(test_util::CreateEmptyExtension());
566 function->set_extension(extension.get());
567
568 scoped_ptr<base::DictionaryValue> result(
569 utils::ToDictionary(utils::RunFunctionAndReturnSingleResult(
570 function.get(), "[{\"state\": \"fullscreen\"}]", browser(),
571 utils::INCLUDE_INCOGNITO)));
572 int window_id = api_test_utils::GetInteger(result.get(), "id");
573 std::string error;
574 Browser* new_window = ExtensionTabUtil::GetBrowserFromWindowID(
575 function.get(), window_id, &error);
576 EXPECT_TRUE(new_window->window()->IsFullscreen());
tapted 2015/04/01 03:41:55 EXPECT_TRUE(error.empty()) ?
limasdf 2015/04/15 23:34:49 Done.
577
578 function = new WindowsCreateFunction();
579 function->set_extension(extension.get());
580 result.reset(utils::ToDictionary(utils::RunFunctionAndReturnSingleResult(
581 function.get(), "[{\"state\": \"minimized\"}]", browser(),
582 utils::INCLUDE_INCOGNITO)));
583 window_id = api_test_utils::GetInteger(result.get(), "id");
584 new_window = ExtensionTabUtil::GetBrowserFromWindowID(function.get(),
585 window_id, &error);
tapted 2015/04/01 03:41:55 same here, immediately after this line. Perhaps a
limasdf 2015/04/15 23:34:49 Done for |error|. `EXPECT_TRUE(new_window);` is no
586 #if !defined(OS_LINUX) || defined(OS_CHROMEOS)
587 // DesktopWindowTreeHostX11::IsMinimized() relies on an asynchronous update
588 // from the window server.
589 EXPECT_TRUE(new_window->window()->IsMinimized());
590 #endif
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698