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

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

Issue 292713003: Session restore shouldn't care about profile home pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: disable 2 tests on mac (they fail after "fixed") Created 6 years, 7 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 | Annotate | Revision Log
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"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/extensions/api/tabs/tabs_api.h" 14 #include "chrome/browser/extensions/api/tabs/tabs_api.h"
15 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" 15 #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
16 #include "chrome/browser/extensions/extension_function_test_utils.h" 16 #include "chrome/browser/extensions/extension_function_test_utils.h"
17 #include "chrome/browser/extensions/extension_tab_util.h" 17 #include "chrome/browser/extensions/extension_tab_util.h"
18 #include "chrome/browser/prefs/incognito_mode_prefs.h" 18 #include "chrome/browser/prefs/incognito_mode_prefs.h"
19 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/ui/browser.h" 20 #include "chrome/browser/ui/browser.h"
21 #include "chrome/browser/ui/browser_commands.h" 21 #include "chrome/browser/ui/browser_commands.h"
22 #include "chrome/browser/ui/browser_window.h" 22 #include "chrome/browser/ui/browser_window.h"
23 #include "chrome/test/base/in_process_browser_test.h" 23 #include "chrome/test/base/in_process_browser_test.h"
24 #include "chrome/test/base/ui_test_utils.h" 24 #include "chrome/test/base/ui_test_utils.h"
25 #include "content/public/common/url_constants.h"
25 #include "ui/gfx/rect.h" 26 #include "ui/gfx/rect.h"
26 27
27 namespace extensions { 28 namespace extensions {
28 29
29 namespace keys = tabs_constants; 30 namespace keys = tabs_constants;
30 namespace utils = extension_function_test_utils; 31 namespace utils = extension_function_test_utils;
31 32
32 namespace { 33 namespace {
33 34
34 class ExtensionTabsTest : public InProcessBrowserTest { 35 class ExtensionTabsTest : public InProcessBrowserTest {
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 kArgs, 386 kArgs,
386 incognito_browser), 387 incognito_browser),
387 keys::kIncognitoModeIsDisabled)); 388 keys::kIncognitoModeIsDisabled));
388 } 389 }
389 390
390 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, QueryCurrentWindowTabs) { 391 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, QueryCurrentWindowTabs) {
391 const size_t kExtraWindows = 3; 392 const size_t kExtraWindows = 3;
392 for (size_t i = 0; i < kExtraWindows; ++i) 393 for (size_t i = 0; i < kExtraWindows; ++i)
393 CreateBrowser(browser()->profile()); 394 CreateBrowser(browser()->profile());
394 395
395 GURL url; 396 GURL url(content::kAboutBlankURL);
396 AddTabAtIndexToBrowser(browser(), 0, url, content::PAGE_TRANSITION_LINK); 397 AddTabAtIndexToBrowser(browser(), 0, url, content::PAGE_TRANSITION_LINK);
397 int window_id = ExtensionTabUtil::GetWindowId(browser()); 398 int window_id = ExtensionTabUtil::GetWindowId(browser());
398 399
399 // Get tabs in the 'current' window called from non-focused browser. 400 // Get tabs in the 'current' window called from non-focused browser.
400 scoped_refptr<TabsQueryFunction> function = new TabsQueryFunction(); 401 scoped_refptr<TabsQueryFunction> function = new TabsQueryFunction();
401 function->set_extension(utils::CreateEmptyExtension().get()); 402 function->set_extension(utils::CreateEmptyExtension().get());
402 scoped_ptr<base::ListValue> result(utils::ToList( 403 scoped_ptr<base::ListValue> result(utils::ToList(
403 utils::RunFunctionAndReturnSingleResult(function.get(), 404 utils::RunFunctionAndReturnSingleResult(function.get(),
404 "[{\"currentWindow\":true}]", 405 "[{\"currentWindow\":true}]",
405 browser()))); 406 browser())));
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 function->set_extension(extension.get()); 503 function->set_extension(extension.get());
503 EXPECT_TRUE(MatchPattern( 504 EXPECT_TRUE(MatchPattern(
504 utils::RunFunctionAndReturnError( 505 utils::RunFunctionAndReturnError(
505 function.get(), 506 function.get(),
506 base::StringPrintf(kArgsMaximizedWithBounds, window_id), 507 base::StringPrintf(kArgsMaximizedWithBounds, window_id),
507 browser()), 508 browser()),
508 keys::kInvalidWindowStateError)); 509 keys::kInvalidWindowStateError));
509 } 510 }
510 511
511 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DuplicateTab) { 512 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DuplicateTab) {
512 static const char kNewBlankTabArgs[] ="about:blank"; 513 content::OpenURLParams params(GURL(content::kAboutBlankURL),
513 514 content::Referrer(),
514 content::OpenURLParams params(GURL(kNewBlankTabArgs), content::Referrer(),
515 NEW_FOREGROUND_TAB, 515 NEW_FOREGROUND_TAB,
516 content::PAGE_TRANSITION_LINK, false); 516 content::PAGE_TRANSITION_LINK, false);
517 content::WebContents* web_contents = browser()->OpenURL(params); 517 content::WebContents* web_contents = browser()->OpenURL(params);
518 int tab_id = ExtensionTabUtil::GetTabId(web_contents); 518 int tab_id = ExtensionTabUtil::GetTabId(web_contents);
519 int window_id = ExtensionTabUtil::GetWindowIdOfTab(web_contents); 519 int window_id = ExtensionTabUtil::GetWindowIdOfTab(web_contents);
520 int tab_index = -1; 520 int tab_index = -1;
521 TabStripModel* tab_strip; 521 TabStripModel* tab_strip;
522 ExtensionTabUtil::GetTabStripModel(web_contents, &tab_strip, &tab_index); 522 ExtensionTabUtil::GetTabStripModel(web_contents, &tab_strip, &tab_index);
523 523
524 scoped_refptr<TabsDuplicateFunction> duplicate_tab_function( 524 scoped_refptr<TabsDuplicateFunction> duplicate_tab_function(
(...skipping 21 matching lines...) Expand all
546 EXPECT_NE(tab_id, duplicate_tab_id); 546 EXPECT_NE(tab_id, duplicate_tab_id);
547 EXPECT_EQ(window_id, duplicate_tab_window_id); 547 EXPECT_EQ(window_id, duplicate_tab_window_id);
548 EXPECT_EQ(tab_index + 1, duplicate_tab_index); 548 EXPECT_EQ(tab_index + 1, duplicate_tab_index);
549 // The test empty tab extension has tabs permissions, therefore 549 // The test empty tab extension has tabs permissions, therefore
550 // |duplicate_result| should contain url, title, and faviconUrl 550 // |duplicate_result| should contain url, title, and faviconUrl
551 // in the function result. 551 // in the function result.
552 EXPECT_TRUE(utils::HasPrivacySensitiveFields(duplicate_result.get())); 552 EXPECT_TRUE(utils::HasPrivacySensitiveFields(duplicate_result.get()));
553 } 553 }
554 554
555 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DuplicateTabNoPermission) { 555 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DuplicateTabNoPermission) {
556 static const char kNewBlankTabArgs[] ="about:blank"; 556 content::OpenURLParams params(GURL(content::kAboutBlankURL),
557 557 content::Referrer(),
558 content::OpenURLParams params(GURL(kNewBlankTabArgs), content::Referrer(),
559 NEW_FOREGROUND_TAB, 558 NEW_FOREGROUND_TAB,
560 content::PAGE_TRANSITION_LINK, false); 559 content::PAGE_TRANSITION_LINK, false);
561 content::WebContents* web_contents = browser()->OpenURL(params); 560 content::WebContents* web_contents = browser()->OpenURL(params);
562 int tab_id = ExtensionTabUtil::GetTabId(web_contents); 561 int tab_id = ExtensionTabUtil::GetTabId(web_contents);
563 int window_id = ExtensionTabUtil::GetWindowIdOfTab(web_contents); 562 int window_id = ExtensionTabUtil::GetWindowIdOfTab(web_contents);
564 int tab_index = -1; 563 int tab_index = -1;
565 TabStripModel* tab_strip; 564 TabStripModel* tab_strip;
566 ExtensionTabUtil::GetTabStripModel(web_contents, &tab_strip, &tab_index); 565 ExtensionTabUtil::GetTabStripModel(web_contents, &tab_strip, &tab_index);
567 566
568 scoped_refptr<TabsDuplicateFunction> duplicate_tab_function( 567 scoped_refptr<TabsDuplicateFunction> duplicate_tab_function(
(...skipping 15 matching lines...) Expand all
584 // Duplicate tab id should be different from the original tab id. 583 // Duplicate tab id should be different from the original tab id.
585 EXPECT_NE(tab_id, duplicate_tab_id); 584 EXPECT_NE(tab_id, duplicate_tab_id);
586 EXPECT_EQ(window_id, duplicate_tab_window_id); 585 EXPECT_EQ(window_id, duplicate_tab_window_id);
587 EXPECT_EQ(tab_index + 1, duplicate_tab_index); 586 EXPECT_EQ(tab_index + 1, duplicate_tab_index);
588 // The test empty extension has no permissions, therefore |duplicate_result| 587 // The test empty extension has no permissions, therefore |duplicate_result|
589 // should not contain url, title, and faviconUrl in the function result. 588 // should not contain url, title, and faviconUrl in the function result.
590 EXPECT_FALSE(utils::HasPrivacySensitiveFields(duplicate_result.get())); 589 EXPECT_FALSE(utils::HasPrivacySensitiveFields(duplicate_result.get()));
591 } 590 }
592 591
593 } // namespace extensions 592 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/download/download_browsertest.cc ('k') | chrome/browser/extensions/extension_api_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698