OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/ui/website_settings/mock_permission_bubble_request.h" | 8 #include "chrome/browser/ui/website_settings/mock_permission_bubble_request.h" |
9 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" | 9 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" |
10 #include "chrome/browser/ui/website_settings/permission_bubble_request.h" | 10 #include "chrome/browser/ui/website_settings/permission_bubble_request.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 void Clear() { | 23 void Clear() { |
24 shown_ = false; | 24 shown_ = false; |
25 can_accept_updates_ = true; | 25 can_accept_updates_ = true; |
26 delegate_ = NULL; | 26 delegate_ = NULL; |
27 permission_requests_.clear(); | 27 permission_requests_.clear(); |
28 permission_states_.clear(); | 28 permission_states_.clear(); |
29 } | 29 } |
30 | 30 |
31 // PermissionBubbleView: | 31 // PermissionBubbleView: |
32 virtual void SetDelegate(Delegate* delegate) OVERRIDE { | 32 virtual void SetDelegate(Delegate* delegate) override { |
33 delegate_ = delegate; | 33 delegate_ = delegate; |
34 } | 34 } |
35 | 35 |
36 virtual void Show( | 36 virtual void Show( |
37 const std::vector<PermissionBubbleRequest*>& requests, | 37 const std::vector<PermissionBubbleRequest*>& requests, |
38 const std::vector<bool>& accept_state, | 38 const std::vector<bool>& accept_state, |
39 bool customization_state_) OVERRIDE { | 39 bool customization_state_) override { |
40 shown_ = true; | 40 shown_ = true; |
41 permission_requests_ = requests; | 41 permission_requests_ = requests; |
42 permission_states_ = accept_state; | 42 permission_states_ = accept_state; |
43 } | 43 } |
44 | 44 |
45 virtual void Hide() OVERRIDE { | 45 virtual void Hide() override { |
46 shown_ = false; | 46 shown_ = false; |
47 } | 47 } |
48 | 48 |
49 virtual bool CanAcceptRequestUpdate() OVERRIDE { | 49 virtual bool CanAcceptRequestUpdate() override { |
50 return can_accept_updates_; | 50 return can_accept_updates_; |
51 } | 51 } |
52 | 52 |
53 virtual bool IsVisible() OVERRIDE { | 53 virtual bool IsVisible() override { |
54 return shown_; | 54 return shown_; |
55 } | 55 } |
56 | 56 |
57 bool shown_; | 57 bool shown_; |
58 bool can_accept_updates_; | 58 bool can_accept_updates_; |
59 Delegate* delegate_; | 59 Delegate* delegate_; |
60 std::vector<PermissionBubbleRequest*> permission_requests_; | 60 std::vector<PermissionBubbleRequest*> permission_requests_; |
61 std::vector<bool> permission_states_; | 61 std::vector<bool> permission_states_; |
62 }; | 62 }; |
63 | 63 |
64 } // namespace | 64 } // namespace |
65 | 65 |
66 class PermissionBubbleManagerTest : public ChromeRenderViewHostTestHarness { | 66 class PermissionBubbleManagerTest : public ChromeRenderViewHostTestHarness { |
67 public: | 67 public: |
68 PermissionBubbleManagerTest() | 68 PermissionBubbleManagerTest() |
69 : ChromeRenderViewHostTestHarness(), | 69 : ChromeRenderViewHostTestHarness(), |
70 request1_("test1"), | 70 request1_("test1"), |
71 request2_("test2"), | 71 request2_("test2"), |
72 iframe_request_same_domain_("iframe", | 72 iframe_request_same_domain_("iframe", |
73 GURL("http://www.google.com/some/url")), | 73 GURL("http://www.google.com/some/url")), |
74 iframe_request_other_domain_("iframe", | 74 iframe_request_other_domain_("iframe", |
75 GURL("http://www.youtube.com")) {} | 75 GURL("http://www.youtube.com")) {} |
76 virtual ~PermissionBubbleManagerTest() {} | 76 virtual ~PermissionBubbleManagerTest() {} |
77 | 77 |
78 virtual void SetUp() OVERRIDE { | 78 virtual void SetUp() override { |
79 ChromeRenderViewHostTestHarness::SetUp(); | 79 ChromeRenderViewHostTestHarness::SetUp(); |
80 SetContents(CreateTestWebContents()); | 80 SetContents(CreateTestWebContents()); |
81 NavigateAndCommit(GURL("http://www.google.com")); | 81 NavigateAndCommit(GURL("http://www.google.com")); |
82 | 82 |
83 manager_.reset(new PermissionBubbleManager(web_contents())); | 83 manager_.reset(new PermissionBubbleManager(web_contents())); |
84 } | 84 } |
85 | 85 |
86 virtual void TearDown() OVERRIDE { | 86 virtual void TearDown() override { |
87 manager_.reset(); | 87 manager_.reset(); |
88 ChromeRenderViewHostTestHarness::TearDown(); | 88 ChromeRenderViewHostTestHarness::TearDown(); |
89 } | 89 } |
90 | 90 |
91 void ToggleAccept(int index, bool value) { | 91 void ToggleAccept(int index, bool value) { |
92 manager_->ToggleAccept(index, value); | 92 manager_->ToggleAccept(index, value); |
93 } | 93 } |
94 | 94 |
95 void Accept() { | 95 void Accept() { |
96 manager_->Accept(); | 96 manager_->Accept(); |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 EXPECT_FALSE(request2_.finished()); | 523 EXPECT_FALSE(request2_.finished()); |
524 EXPECT_FALSE(iframe_request_other_domain_.finished()); | 524 EXPECT_FALSE(iframe_request_other_domain_.finished()); |
525 EXPECT_TRUE(view_.shown_); | 525 EXPECT_TRUE(view_.shown_); |
526 Closing(); | 526 Closing(); |
527 EXPECT_TRUE(request2_.finished()); | 527 EXPECT_TRUE(request2_.finished()); |
528 EXPECT_FALSE(iframe_request_other_domain_.finished()); | 528 EXPECT_FALSE(iframe_request_other_domain_.finished()); |
529 Closing(); | 529 Closing(); |
530 EXPECT_TRUE(iframe_request_other_domain_.finished()); | 530 EXPECT_TRUE(iframe_request_other_domain_.finished()); |
531 EXPECT_FALSE(view_.shown_); | 531 EXPECT_FALSE(view_.shown_); |
532 } | 532 } |
OLD | NEW |