OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "gtest/gtest.h" | 5 #include "gtest/gtest.h" |
6 #include "gmock/gmock.h" | 6 #include "gmock/gmock.h" |
7 #include "chrome_frame/chrome_frame_automation.h" | 7 #include "chrome_frame/chrome_frame_automation.h" |
8 #include "chrome_frame/chrome_frame_npapi.h" | 8 #include "chrome_frame/chrome_frame_npapi.h" |
9 #include "chrome_frame/ff_privilege_check.h" | 9 #include "chrome_frame/ff_privilege_check.h" |
10 | 10 |
11 | |
12 TEST(ChromeFrameNPAPI, DoesNotCrashOnConstruction) { | 11 TEST(ChromeFrameNPAPI, DoesNotCrashOnConstruction) { |
13 ChromeFrameNPAPI* api = new ChromeFrameNPAPI(); | 12 ChromeFrameNPAPI* api = new ChromeFrameNPAPI(); |
14 delete api; | 13 delete api; |
15 } | 14 } |
16 | 15 |
17 | 16 |
18 // All mocks in the anonymous namespace. | 17 // All mocks in the anonymous namespace. |
19 namespace { | 18 namespace { |
20 | 19 |
21 using ::testing::_; | 20 using ::testing::_; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 ChromeFrameAutomationClient* CreateAutomationClient() { | 73 ChromeFrameAutomationClient* CreateAutomationClient() { |
75 return mock_automation_client_; | 74 return mock_automation_client_; |
76 } | 75 } |
77 | 76 |
78 ChromeFrameAutomationClient* mock_automation_client_; | 77 ChromeFrameAutomationClient* mock_automation_client_; |
79 }; | 78 }; |
80 | 79 |
81 class MockAutomationClient: public ChromeFrameAutomationClient { | 80 class MockAutomationClient: public ChromeFrameAutomationClient { |
82 public: | 81 public: |
83 MOCK_METHOD6(Initialize, bool(ChromeFrameDelegate*, int, bool, | 82 MOCK_METHOD6(Initialize, bool(ChromeFrameDelegate*, int, bool, |
84 const std::wstring&, const std::wstring&, | 83 const FilePath&, const std::wstring&, |
85 bool)); | 84 bool)); |
86 MOCK_METHOD1(SetEnableExtensionAutomation, | 85 MOCK_METHOD1(SetEnableExtensionAutomation, |
87 void(const std::vector<std::string>&)); // NOLINT | 86 void(const std::vector<std::string>&)); // NOLINT |
88 }; | 87 }; |
89 | 88 |
90 class MockProxyService: public NpProxyService { | 89 class MockProxyService: public NpProxyService { |
91 public: | 90 public: |
92 MOCK_METHOD2(Initialize, bool(NPP instance, ChromeFrameAutomationClient*)); | 91 MOCK_METHOD2(Initialize, bool(NPP instance, ChromeFrameAutomationClient*)); |
93 }; | 92 }; |
94 | 93 |
(...skipping 25 matching lines...) Expand all Loading... |
120 EXPECT_CALL(mock_api, GetLocation()) | 119 EXPECT_CALL(mock_api, GetLocation()) |
121 .WillOnce(Return(std::string("http://www.google.com"))); | 120 .WillOnce(Return(std::string("http://www.google.com"))); |
122 EXPECT_CALL(mock_api, CreatePrefService()) | 121 EXPECT_CALL(mock_api, CreatePrefService()) |
123 .WillOnce(Return(mock_proxy)); | 122 .WillOnce(Return(mock_proxy)); |
124 EXPECT_CALL(mock_api, GetBrowserIncognitoMode()) | 123 EXPECT_CALL(mock_api, GetBrowserIncognitoMode()) |
125 .WillOnce(Return(is_incognito)); | 124 .WillOnce(Return(is_incognito)); |
126 | 125 |
127 EXPECT_CALL(*mock_proxy, Initialize(_, _)).WillRepeatedly(Return(false)); | 126 EXPECT_CALL(*mock_proxy, Initialize(_, _)).WillRepeatedly(Return(false)); |
128 | 127 |
129 EXPECT_CALL(*mock_automation, | 128 EXPECT_CALL(*mock_automation, |
130 Initialize(_, _, true, StrEq(profile_name), StrEq(extra_args), false)) | 129 Initialize(_, _, true, _, StrEq(extra_args), false)) |
131 .WillOnce(Return(true)); | 130 .WillOnce(Return(true)); |
132 | 131 |
133 if (expect_privilege_check) { | 132 if (expect_privilege_check) { |
134 EXPECT_CALL(mock_priv, IsFireFoxPrivilegedInvocation(_)) | 133 EXPECT_CALL(mock_priv, IsFireFoxPrivilegedInvocation(_)) |
135 .WillOnce(Return(is_privileged)); | 134 .WillOnce(Return(is_privileged)); |
136 } else { | 135 } else { |
137 EXPECT_CALL(mock_priv, IsFireFoxPrivilegedInvocation(_)) | 136 EXPECT_CALL(mock_priv, IsFireFoxPrivilegedInvocation(_)) |
138 .Times(0); // Fail if privilege check invoked. | 137 .Times(0); // Fail if privilege check invoked. |
139 } | 138 } |
140 } | 139 } |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 // And fething it should return the value we just set. | 542 // And fething it should return the value we just set. |
544 VOID_TO_NPVARIANT(var); | 543 VOID_TO_NPVARIANT(var); |
545 EXPECT_TRUE(mock_api.GetProperty(kOnPrivateMessageId, &var)); | 544 EXPECT_TRUE(mock_api.GetProperty(kOnPrivateMessageId, &var)); |
546 EXPECT_TRUE(NPVARIANT_IS_OBJECT(var)); | 545 EXPECT_TRUE(NPVARIANT_IS_OBJECT(var)); |
547 EXPECT_EQ(kMockNPObject, NPVARIANT_TO_OBJECT(var)); | 546 EXPECT_EQ(kMockNPObject, NPVARIANT_TO_OBJECT(var)); |
548 | 547 |
549 mock_api.Uninitialize(); | 548 mock_api.Uninitialize(); |
550 } | 549 } |
551 | 550 |
552 // TODO(siggi): test invoking postPrivateMessage. | 551 // TODO(siggi): test invoking postPrivateMessage. |
OLD | NEW |