OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/macros.h" | 5 #include "base/macros.h" |
6 #include "chrome/browser/extensions/extension_browsertest.h" | 6 #include "chrome/browser/extensions/extension_browsertest.h" |
7 #include "chrome/browser/extensions/extension_toolbar_model.h" | 7 #include "chrome/browser/extensions/extension_toolbar_model.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/test/base/in_process_browser_test.h" | 10 #include "chrome/test/base/in_process_browser_test.h" |
11 | 11 |
12 namespace extensions { | 12 namespace extensions { |
13 | 13 |
14 // An InProcessBrowserTest for testing the ExtensionToolbarModel. | 14 // An InProcessBrowserTest for testing the ExtensionToolbarModel. |
15 // TODO(erikkay) It's unfortunate that this needs to be an in-proc browser test. | 15 // TODO(erikkay) It's unfortunate that this needs to be an in-proc browser test. |
16 // It would be nice to refactor things so that ExtensionService could run | 16 // It would be nice to refactor things so that ExtensionService could run |
17 // without so much of the browser in place. | 17 // without so much of the browser in place. |
18 class ExtensionToolbarModelTest : public ExtensionBrowserTest, | 18 class ExtensionToolbarModelTest : public ExtensionBrowserTest, |
19 public ExtensionToolbarModel::Observer { | 19 public ExtensionToolbarModel::Observer { |
20 public: | 20 public: |
21 virtual void SetUp() { | 21 virtual void SetUp() { |
22 inserted_count_ = 0; | 22 inserted_count_ = 0; |
23 removed_count_ = 0; | 23 removed_count_ = 0; |
24 moved_count_ = 0; | 24 moved_count_ = 0; |
25 highlight_mode_count_ = 0; | 25 highlight_mode_count_ = 0; |
26 | 26 |
27 ExtensionBrowserTest::SetUp(); | 27 ExtensionBrowserTest::SetUp(); |
28 } | 28 } |
29 | 29 |
| 30 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 31 ExtensionBrowserTest::SetUpCommandLine(command_line); |
| 32 #if defined(OS_LINUX) || defined(OS_CHROMEOS) |
| 33 command_line->AppendSwitchNative( |
| 34 "vmodule", "*extension_toolbar_model*=4,*browser_actions_container*=4"); |
| 35 #endif // defined(OS_LINUX) || defined(OS_CHROMEOS) |
| 36 } |
| 37 |
30 virtual void SetUpOnMainThread() OVERRIDE { | 38 virtual void SetUpOnMainThread() OVERRIDE { |
31 model_ = ExtensionToolbarModel::Get(browser()->profile()); | 39 model_ = ExtensionToolbarModel::Get(browser()->profile()); |
32 model_->AddObserver(this); | 40 model_->AddObserver(this); |
33 } | 41 } |
34 | 42 |
35 virtual void CleanUpOnMainThread() OVERRIDE { | 43 virtual void CleanUpOnMainThread() OVERRIDE { |
36 model_->RemoveObserver(this); | 44 model_->RemoveObserver(this); |
37 } | 45 } |
38 | 46 |
39 virtual void BrowserActionAdded(const Extension* extension, | 47 virtual void BrowserActionAdded(const Extension* extension, |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 | 585 |
578 // When we stop highlighting, we should see the new extension show up. | 586 // When we stop highlighting, we should see the new extension show up. |
579 model_->StopHighlighting(); | 587 model_->StopHighlighting(); |
580 EXPECT_FALSE(model_->is_highlighting()); | 588 EXPECT_FALSE(model_->is_highlighting()); |
581 EXPECT_EQ(3u, model_->toolbar_items().size()); | 589 EXPECT_EQ(3u, model_->toolbar_items().size()); |
582 EXPECT_EQ(id_a, ExtensionAt(0)->id()); | 590 EXPECT_EQ(id_a, ExtensionAt(0)->id()); |
583 EXPECT_EQ(id_b, ExtensionAt(1)->id()); | 591 EXPECT_EQ(id_b, ExtensionAt(1)->id()); |
584 EXPECT_EQ(id_c, ExtensionAt(2)->id()); | 592 EXPECT_EQ(id_c, ExtensionAt(2)->id()); |
585 } | 593 } |
586 | 594 |
587 // Test is flaky on Linus and ChromeOS, see crbug.com/379170. | 595 // Test is flaky (see crbug.com/379170), but currently enabled to gather traces. |
588 #if defined(OS_LINUX) || defined(OS_CHROMEOS) | 596 // If it fails, ping Finnur. |
589 #define MAYBE_SizeAfterPrefChange DISABLED_SizeAfterPrefChange | 597 IN_PROC_BROWSER_TEST_F(ExtensionToolbarModelTest, SizeAfterPrefChange) { |
590 #else | |
591 #define MAYBE_SizeAfterPrefChange SizeAfterPrefChange | |
592 #endif | |
593 IN_PROC_BROWSER_TEST_F(ExtensionToolbarModelTest, MAYBE_SizeAfterPrefChange) { | |
594 // Load two extensions with browser action. | 598 // Load two extensions with browser action. |
595 base::FilePath extension_a_path(test_data_dir_.AppendASCII("api_test") | 599 base::FilePath extension_a_path(test_data_dir_.AppendASCII("api_test") |
596 .AppendASCII("browser_action") | 600 .AppendASCII("browser_action") |
597 .AppendASCII("basics")); | 601 .AppendASCII("basics")); |
598 LOG(ERROR) << "Loading [basics]"; | 602 VLOG(4) << "Loading [basics]"; |
599 ASSERT_TRUE(LoadExtension(extension_a_path)); | 603 ASSERT_TRUE(LoadExtension(extension_a_path)); |
600 base::FilePath extension_b_path(test_data_dir_.AppendASCII("api_test") | 604 base::FilePath extension_b_path(test_data_dir_.AppendASCII("api_test") |
601 .AppendASCII("browser_action") | 605 .AppendASCII("browser_action") |
602 .AppendASCII("popup")); | 606 .AppendASCII("popup")); |
603 LOG(ERROR) << "Loading [popup]"; | 607 VLOG(4) << "Loading [popup]"; |
604 ASSERT_TRUE(LoadExtension(extension_b_path)); | 608 ASSERT_TRUE(LoadExtension(extension_b_path)); |
605 std::string id_a = ExtensionAt(0)->id(); | 609 std::string id_a = ExtensionAt(0)->id(); |
606 std::string id_b = ExtensionAt(1)->id(); | 610 std::string id_b = ExtensionAt(1)->id(); |
607 | 611 |
608 LOG(ERROR) << "GetVisibleIconCount"; | 612 VLOG(4) << "GetVisibleIconCount"; |
609 | 613 |
610 // Should be at max size (-1). | 614 // Should be at max size (-1). |
611 EXPECT_EQ(-1, model_->GetVisibleIconCount()); | 615 EXPECT_EQ(-1, model_->GetVisibleIconCount()); |
612 | 616 |
613 LOG(ERROR) << "OnExtensionToolbarPrefChange"; | 617 VLOG(4) << "OnExtensionToolbarPrefChange"; |
614 model_->OnExtensionToolbarPrefChange(); | 618 model_->OnExtensionToolbarPrefChange(); |
615 | 619 |
616 LOG(ERROR) << "GetVisibleIconCount"; | 620 VLOG(4) << "GetVisibleIconCount"; |
617 | 621 |
618 // Should still be at max size. | 622 // Should still be at max size. |
619 EXPECT_EQ(-1, model_->GetVisibleIconCount()); | 623 EXPECT_EQ(-1, model_->GetVisibleIconCount()); |
620 } | 624 } |
621 | 625 |
622 } // namespace extensions | 626 } // namespace extensions |
OLD | NEW |