| 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 "chrome/browser/extensions/extension_browsertest.h" | 5 #include "chrome/browser/extensions/extension_browsertest.h" |
| 6 #include "chrome/browser/extensions/extension_service.h" | |
| 7 #include "chrome/browser/extensions/extension_system.h" | |
| 8 #include "chrome/browser/extensions/extension_toolbar_model.h" | 6 #include "chrome/browser/extensions/extension_toolbar_model.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/test/base/in_process_browser_test.h" | 9 #include "chrome/test/base/in_process_browser_test.h" |
| 12 | 10 |
| 13 using extensions::Extension; | 11 using extensions::Extension; |
| 14 | 12 |
| 15 // An InProcessBrowserTest for testing the ExtensionToolbarModel. | 13 // An InProcessBrowserTest for testing the ExtensionToolbarModel. |
| 16 // TODO(erikkay) It's unfortunate that this needs to be an in-proc browser test. | 14 // TODO(erikkay) It's unfortunate that this needs to be an in-proc browser test. |
| 17 // It would be nice to refactor things so that ExtensionService could run | 15 // It would be nice to refactor things so that ExtensionService could run |
| 18 // without so much of the browser in place. | 16 // without so much of the browser in place. |
| 19 class ExtensionToolbarModelTest : public ExtensionBrowserTest, | 17 class ExtensionToolbarModelTest : public ExtensionBrowserTest, |
| 20 public ExtensionToolbarModel::Observer { | 18 public ExtensionToolbarModel::Observer { |
| 21 public: | 19 public: |
| 22 virtual void SetUp() { | 20 virtual void SetUp() { |
| 23 inserted_count_ = 0; | 21 inserted_count_ = 0; |
| 24 removed_count_ = 0; | 22 removed_count_ = 0; |
| 25 moved_count_ = 0; | 23 moved_count_ = 0; |
| 26 | 24 |
| 27 ExtensionBrowserTest::SetUp(); | 25 ExtensionBrowserTest::SetUp(); |
| 28 } | 26 } |
| 29 | 27 |
| 30 virtual void SetUpOnMainThread() OVERRIDE { | 28 virtual void SetUpOnMainThread() OVERRIDE { |
| 31 ExtensionService* service = extensions::ExtensionSystem::Get( | 29 model_ = ExtensionToolbarModel::Get(browser()->profile()); |
| 32 browser()->profile())->extension_service(); | |
| 33 model_ = service->toolbar_model(); | |
| 34 model_->AddObserver(this); | 30 model_->AddObserver(this); |
| 35 } | 31 } |
| 36 | 32 |
| 37 virtual void CleanUpOnMainThread() OVERRIDE { | 33 virtual void CleanUpOnMainThread() OVERRIDE { |
| 38 model_->RemoveObserver(this); | 34 model_->RemoveObserver(this); |
| 39 } | 35 } |
| 40 | 36 |
| 41 virtual void BrowserActionAdded(const Extension* extension, | 37 virtual void BrowserActionAdded(const Extension* extension, |
| 42 int index) OVERRIDE { | 38 int index) OVERRIDE { |
| 43 inserted_count_++; | 39 inserted_count_++; |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 new_order.push_back(id_c); | 366 new_order.push_back(id_c); |
| 371 new_order.push_back(id_b); | 367 new_order.push_back(id_b); |
| 372 extensions::ExtensionPrefs::Get(browser()->profile())->SetToolbarOrder( | 368 extensions::ExtensionPrefs::Get(browser()->profile())->SetToolbarOrder( |
| 373 new_order); | 369 new_order); |
| 374 | 370 |
| 375 // Verify order is changed. | 371 // Verify order is changed. |
| 376 EXPECT_EQ(id_c, ExtensionAt(0)->id()); | 372 EXPECT_EQ(id_c, ExtensionAt(0)->id()); |
| 377 EXPECT_EQ(id_b, ExtensionAt(1)->id()); | 373 EXPECT_EQ(id_b, ExtensionAt(1)->id()); |
| 378 EXPECT_EQ(id_a, ExtensionAt(2)->id()); | 374 EXPECT_EQ(id_a, ExtensionAt(2)->id()); |
| 379 } | 375 } |
| OLD | NEW |