OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "chrome/browser/extensions/./extension_prefs_unittest.h" | 10 #include "chrome/browser/extensions/./extension_prefs_unittest.h" |
11 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 11 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
12 #include "extensions/common/extension.h" | 12 #include "extensions/common/extension.h" |
13 | 13 |
14 namespace extensions { | 14 namespace extensions { |
15 | 15 |
16 // Tests force hiding browser actions. | 16 // Tests force hiding browser actions. |
17 class ExtensionPrefsHidingBrowserActions : public ExtensionPrefsTest { | 17 class ExtensionPrefsHidingBrowserActions : public ExtensionPrefsTest { |
18 public: | 18 public: |
19 virtual void Initialize() OVERRIDE { | 19 virtual void Initialize() override { |
20 // Install 5 extensions. | 20 // Install 5 extensions. |
21 for (int i = 0; i < 5; i++) { | 21 for (int i = 0; i < 5; i++) { |
22 std::string name = "test" + base::IntToString(i); | 22 std::string name = "test" + base::IntToString(i); |
23 extensions_.push_back(prefs_.AddExtension(name)); | 23 extensions_.push_back(prefs_.AddExtension(name)); |
24 } | 24 } |
25 | 25 |
26 ExtensionList::const_iterator iter; | 26 ExtensionList::const_iterator iter; |
27 for (iter = extensions_.begin(); iter != extensions_.end(); ++iter) { | 27 for (iter = extensions_.begin(); iter != extensions_.end(); ++iter) { |
28 EXPECT_TRUE(ExtensionActionAPI::GetBrowserActionVisibility( | 28 EXPECT_TRUE(ExtensionActionAPI::GetBrowserActionVisibility( |
29 prefs(), (*iter)->id())); | 29 prefs(), (*iter)->id())); |
30 } | 30 } |
31 | 31 |
32 ExtensionActionAPI::SetBrowserActionVisibility( | 32 ExtensionActionAPI::SetBrowserActionVisibility( |
33 prefs(), extensions_[0]->id(), false); | 33 prefs(), extensions_[0]->id(), false); |
34 ExtensionActionAPI::SetBrowserActionVisibility( | 34 ExtensionActionAPI::SetBrowserActionVisibility( |
35 prefs(), extensions_[1]->id(), true); | 35 prefs(), extensions_[1]->id(), true); |
36 } | 36 } |
37 | 37 |
38 virtual void Verify() OVERRIDE { | 38 virtual void Verify() override { |
39 // Make sure the one we hid is hidden. | 39 // Make sure the one we hid is hidden. |
40 EXPECT_FALSE(ExtensionActionAPI::GetBrowserActionVisibility( | 40 EXPECT_FALSE(ExtensionActionAPI::GetBrowserActionVisibility( |
41 prefs(), extensions_[0]->id())); | 41 prefs(), extensions_[0]->id())); |
42 | 42 |
43 // Make sure the other id's are not hidden. | 43 // Make sure the other id's are not hidden. |
44 ExtensionList::const_iterator iter = extensions_.begin() + 1; | 44 ExtensionList::const_iterator iter = extensions_.begin() + 1; |
45 for (; iter != extensions_.end(); ++iter) { | 45 for (; iter != extensions_.end(); ++iter) { |
46 SCOPED_TRACE(base::StringPrintf("Loop %d ", | 46 SCOPED_TRACE(base::StringPrintf("Loop %d ", |
47 static_cast<int>(iter - extensions_.begin()))); | 47 static_cast<int>(iter - extensions_.begin()))); |
48 EXPECT_TRUE(ExtensionActionAPI::GetBrowserActionVisibility( | 48 EXPECT_TRUE(ExtensionActionAPI::GetBrowserActionVisibility( |
49 prefs(), (*iter)->id())); | 49 prefs(), (*iter)->id())); |
50 } | 50 } |
51 } | 51 } |
52 | 52 |
53 private: | 53 private: |
54 ExtensionList extensions_; | 54 ExtensionList extensions_; |
55 }; | 55 }; |
56 | 56 |
57 TEST_F(ExtensionPrefsHidingBrowserActions, ForceHide) {} | 57 TEST_F(ExtensionPrefsHidingBrowserActions, ForceHide) {} |
58 | 58 |
59 } // namespace extensions | 59 } // namespace extensions |
OLD | NEW |