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

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

Issue 11414223: Move the test functions that deal with focus to interactive_ui_tets_utils.h and into the interactiv… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years 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 #include "chrome/browser/extensions/api/tabs/tabs.h" 5 #include "chrome/browser/extensions/api/tabs/tabs.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 result_tabs = result.get(); 432 result_tabs = result.get();
433 // We should have one tab for each extra window. 433 // We should have one tab for each extra window.
434 EXPECT_EQ(kExtraWindows, result_tabs->GetSize()); 434 EXPECT_EQ(kExtraWindows, result_tabs->GetSize());
435 for (size_t i = 0; i < kExtraWindows; ++i) { 435 for (size_t i = 0; i < kExtraWindows; ++i) {
436 DictionaryValue* result_tab = NULL; 436 DictionaryValue* result_tab = NULL;
437 EXPECT_TRUE(result_tabs->GetDictionary(i, &result_tab)); 437 EXPECT_TRUE(result_tabs->GetDictionary(i, &result_tab));
438 EXPECT_NE(window_id, utils::GetInteger(result_tab, keys::kWindowIdKey)); 438 EXPECT_NE(window_id, utils::GetInteger(result_tab, keys::kWindowIdKey));
439 } 439 }
440 } 440 }
441 441
442 // Flaky: http://crbug.com/136562
443 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DISABLED_QueryLastFocusedWindowTabs) {
444 const size_t kExtraWindows = 2;
445 for (size_t i = 0; i < kExtraWindows; ++i)
446 CreateBrowser(browser()->profile());
447
448 Browser* focused_window = CreateBrowser(browser()->profile());
449 #if defined(OS_MACOSX)
450 // See BrowserWindowCocoa::Show. In tests, Browser::window()->IsActive won't
451 // work unless we fake the browser being launched by the user.
452 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(
453 focused_window->window()->GetNativeWindow()));
454 #endif
455
456 // Needed on Mac and Linux so that the BrowserWindow::IsActive calls work.
457 content::RunAllPendingInMessageLoop();
458
459 GURL url;
460 AddTabAtIndexToBrowser(focused_window, 0, url, content::PAGE_TRANSITION_LINK);
461 int focused_window_id = ExtensionTabUtil::GetWindowId(focused_window);
462
463 // Get tabs in the 'last focused' window called from non-focused browser.
464 scoped_refptr<QueryTabsFunction> function = new QueryTabsFunction();
465 scoped_ptr<base::ListValue> result(utils::ToList(
466 utils::RunFunctionAndReturnSingleResult(function.get(),
467 "[{\"lastFocusedWindow\":true}]",
468 browser())));
469
470 ListValue* result_tabs = result.get();
471 // We should have one initial tab and one added tab.
472 EXPECT_EQ(2u, result_tabs->GetSize());
473 for (size_t i = 0; i < result_tabs->GetSize(); ++i) {
474 DictionaryValue* result_tab = NULL;
475 EXPECT_TRUE(result_tabs->GetDictionary(i, &result_tab));
476 EXPECT_EQ(focused_window_id, utils::GetInteger(result_tab,
477 keys::kWindowIdKey));
478 }
479
480 // Get tabs NOT in the 'last focused' window called from the focused browser.
481 function = new QueryTabsFunction();
482 result.reset(utils::ToList(
483 utils::RunFunctionAndReturnSingleResult(function.get(),
484 "[{\"lastFocusedWindow\":false}]",
485 browser())));
486
487 result_tabs = result.get();
488 // We should get one tab for each extra window and one for the initial window.
489 EXPECT_EQ(kExtraWindows + 1, result_tabs->GetSize());
490 for (size_t i = 0; i < result_tabs->GetSize(); ++i) {
491 DictionaryValue* result_tab = NULL;
492 EXPECT_TRUE(result_tabs->GetDictionary(i, &result_tab));
493 EXPECT_NE(focused_window_id, utils::GetInteger(result_tab,
494 keys::kWindowIdKey));
495 }
496 }
497
498 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DontCreateTabInClosingPopupWindow) { 442 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DontCreateTabInClosingPopupWindow) {
499 // Test creates new popup window, closes it right away and then tries to open 443 // Test creates new popup window, closes it right away and then tries to open
500 // a new tab in it. Tab should not be opened in the popup window, but in a 444 // a new tab in it. Tab should not be opened in the popup window, but in a
501 // tabbed browser window. 445 // tabbed browser window.
502 Browser* popup_browser = new Browser( 446 Browser* popup_browser = new Browser(
503 Browser::CreateParams(Browser::TYPE_POPUP, browser()->profile())); 447 Browser::CreateParams(Browser::TYPE_POPUP, browser()->profile()));
504 int window_id = ExtensionTabUtil::GetWindowId(popup_browser); 448 int window_id = ExtensionTabUtil::GetWindowId(popup_browser);
505 chrome::CloseWindow(popup_browser); 449 chrome::CloseWindow(popup_browser);
506 450
507 scoped_refptr<CreateTabFunction> create_tab_function(new CreateTabFunction()); 451 scoped_refptr<CreateTabFunction> create_tab_function(new CreateTabFunction());
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 int duplicate_tab_index = utils::GetInteger(duplicate_result.get(), "index"); 589 int duplicate_tab_index = utils::GetInteger(duplicate_result.get(), "index");
646 EXPECT_EQ(base::Value::TYPE_DICTIONARY, duplicate_result->GetType()); 590 EXPECT_EQ(base::Value::TYPE_DICTIONARY, duplicate_result->GetType());
647 // Duplicate tab id should be different from the original tab id. 591 // Duplicate tab id should be different from the original tab id.
648 EXPECT_NE(tab_id, duplicate_tab_id); 592 EXPECT_NE(tab_id, duplicate_tab_id);
649 EXPECT_EQ(window_id, duplicate_tab_window_id); 593 EXPECT_EQ(window_id, duplicate_tab_window_id);
650 EXPECT_EQ(tab_index + 1, duplicate_tab_index); 594 EXPECT_EQ(tab_index + 1, duplicate_tab_index);
651 // The test empty extension has no permissions, therefore |duplicate_result| 595 // The test empty extension has no permissions, therefore |duplicate_result|
652 // should not contain url, title, and faviconUrl in the function result. 596 // should not contain url, title, and faviconUrl in the function result.
653 EXPECT_FALSE(utils::HasPrivacySensitiveFields(duplicate_result.get())); 597 EXPECT_FALSE(utils::HasPrivacySensitiveFields(duplicate_result.get()));
654 } 598 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698