OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/extensions_service.h" | 6 #include "chrome/browser/extensions/extension_service.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/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
11 #include "chrome/test/in_process_browser_test.h" | 11 #include "chrome/test/in_process_browser_test.h" |
12 | 12 |
13 // An InProcessBrowserTest for testing the ExtensionToolbarModel. | 13 // An InProcessBrowserTest for testing the ExtensionToolbarModel. |
14 // 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. |
15 // It would be nice to refactor things so that ExtensionsService could run | 15 // It would be nice to refactor things so that ExtensionService could run |
16 // without so much of the browser in place. | 16 // without so much of the browser in place. |
17 class ExtensionToolbarModelTest : public ExtensionBrowserTest, | 17 class ExtensionToolbarModelTest : public ExtensionBrowserTest, |
18 public ExtensionToolbarModel::Observer { | 18 public ExtensionToolbarModel::Observer { |
19 public: | 19 public: |
20 virtual void SetUp() { | 20 virtual void SetUp() { |
21 inserted_count_ = 0; | 21 inserted_count_ = 0; |
22 removed_count_ = 0; | 22 removed_count_ = 0; |
23 moved_count_ = 0; | 23 moved_count_ = 0; |
24 | 24 |
25 ExtensionBrowserTest::SetUp(); | 25 ExtensionBrowserTest::SetUp(); |
26 } | 26 } |
27 | 27 |
28 virtual Browser* CreateBrowser(Profile* profile) { | 28 virtual Browser* CreateBrowser(Profile* profile) { |
29 Browser* b = InProcessBrowserTest::CreateBrowser(profile); | 29 Browser* b = InProcessBrowserTest::CreateBrowser(profile); |
30 ExtensionsService* service = b->profile()->GetExtensionsService(); | 30 ExtensionService* service = b->profile()->GetExtensionService(); |
31 model_ = service->toolbar_model(); | 31 model_ = service->toolbar_model(); |
32 model_->AddObserver(this); | 32 model_->AddObserver(this); |
33 return b; | 33 return b; |
34 } | 34 } |
35 | 35 |
36 virtual void CleanUpOnMainThread() { | 36 virtual void CleanUpOnMainThread() { |
37 model_->RemoveObserver(this); | 37 model_->RemoveObserver(this); |
38 } | 38 } |
39 | 39 |
40 virtual void BrowserActionAdded(const Extension* extension, int index) { | 40 virtual void BrowserActionAdded(const Extension* extension, int index) { |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 221 |
222 // Load extension C again. | 222 // Load extension C again. |
223 ASSERT_TRUE(LoadExtension(extension_c_path)); | 223 ASSERT_TRUE(LoadExtension(extension_c_path)); |
224 | 224 |
225 // Extension C loaded again. | 225 // Extension C loaded again. |
226 EXPECT_EQ(5, inserted_count_); | 226 EXPECT_EQ(5, inserted_count_); |
227 EXPECT_EQ(2u, model_->size()); | 227 EXPECT_EQ(2u, model_->size()); |
228 // Make sure it gets its old spot in the list (at the very end). | 228 // Make sure it gets its old spot in the list (at the very end). |
229 ASSERT_STREQ(idC.c_str(), ExtensionAt(1)->id().c_str()); | 229 ASSERT_STREQ(idC.c_str(), ExtensionAt(1)->id().c_str()); |
230 } | 230 } |
OLD | NEW |