Chromium Code Reviews| 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 #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 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 540 | 540 |
| 541 static const char kArgsMaximizedWithBounds[] = | 541 static const char kArgsMaximizedWithBounds[] = |
| 542 "[%u, {\"state\": \"maximized\", \"width\": 500}]"; | 542 "[%u, {\"state\": \"maximized\", \"width\": 500}]"; |
| 543 EXPECT_TRUE(MatchPattern( | 543 EXPECT_TRUE(MatchPattern( |
| 544 utils::RunFunctionAndReturnError( | 544 utils::RunFunctionAndReturnError( |
| 545 new UpdateWindowFunction(), | 545 new UpdateWindowFunction(), |
| 546 base::StringPrintf(kArgsMaximizedWithBounds, window_id), | 546 base::StringPrintf(kArgsMaximizedWithBounds, window_id), |
| 547 browser()), | 547 browser()), |
| 548 keys::kInvalidWindowStateError)); | 548 keys::kInvalidWindowStateError)); |
| 549 } | 549 } |
| 550 | |
| 551 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DuplicateTabNoPermission) { | |
|
Aaron Boodman
2012/07/16 21:37:59
What about a test for when the extension has the p
SanjoyPal
2012/07/17 10:39:56
Done.
| |
| 552 scoped_refptr<CreateTabFunction> create_tab_function(new CreateTabFunction()); | |
| 553 // Without a callback the function will not generate a result. | |
| 554 create_tab_function->set_has_callback(true); | |
| 555 | |
| 556 static const char kNewBlankTabArgs[] = | |
| 557 "[{\"url\": \"about:blank\"}]"; | |
| 558 | |
| 559 scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( | |
| 560 utils::RunFunctionAndReturnResult( | |
| 561 create_tab_function.get(), | |
| 562 kNewBlankTabArgs, | |
| 563 browser()))); | |
| 564 | |
| 565 int tab_id = utils::GetInteger(result.get(), "id"); | |
| 566 int tab_index = utils::GetInteger(result.get(), "index"); | |
| 567 | |
| 568 scoped_refptr<DuplicateTabFunction> duplicate_tab_function( | |
| 569 new DuplicateTabFunction()); | |
| 570 scoped_refptr<extensions::Extension> empty_extension( | |
| 571 utils::CreateEmptyExtension()); | |
| 572 duplicate_tab_function->set_extension(empty_extension.get()); | |
| 573 // Without a callback the function will not generate a result. | |
| 574 duplicate_tab_function->set_has_callback(true); | |
| 575 | |
| 576 scoped_ptr<base::DictionaryValue> duplicate_result(utils::ToDictionary( | |
| 577 utils::RunFunctionAndReturnResult( | |
| 578 duplicate_tab_function.get(), base::StringPrintf("[%u]", tab_id), | |
| 579 browser()))); | |
| 580 | |
| 581 int duplicate_tab_id = utils::GetInteger(duplicate_result.get(), "id"); | |
| 582 int duplicate_tab_index = utils::GetInteger(duplicate_result.get(), "index"); | |
| 583 // The test empty extension has no permissions, therefore it should get | |
| 584 // tab id of TYPE_INTEGER in the function result. | |
|
Aaron Boodman
2012/07/16 21:37:59
Comment is out of date.
SanjoyPal
2012/07/17 10:39:56
Done.
| |
| 585 EXPECT_EQ(base::Value::TYPE_DICTIONARY, duplicate_result->GetType()); | |
| 586 // Duplicate tab id should be different from the original tab id. | |
| 587 EXPECT_NE(tab_id, duplicate_tab_id); | |
| 588 EXPECT_EQ(tab_index + 1, duplicate_tab_index); | |
|
Aaron Boodman
2012/07/16 21:37:59
Can you test that URL, faviconURL, and title are *
SanjoyPal
2012/07/17 10:39:56
Done.
| |
| 589 } | |
| 590 | |
|
Aaron Boodman
2012/07/16 21:37:59
extraneous blank line
SanjoyPal
2012/07/17 10:39:56
Done.
| |
| OLD | NEW |