Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: chrome_frame/chrome_frame_npapi_unittest.cc

Issue 3061036: Handle automation server crashes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome_frame/chrome_frame_automation.cc ('k') | chrome_frame/chrome_frame_plugin.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 ChromeFrameAutomationClient* CreateAutomationClient() { 74 ChromeFrameAutomationClient* CreateAutomationClient() {
75 return mock_automation_client_; 75 return mock_automation_client_;
76 } 76 }
77 77
78 ChromeFrameAutomationClient* mock_automation_client_; 78 ChromeFrameAutomationClient* mock_automation_client_;
79 }; 79 };
80 80
81 class MockAutomationClient: public ChromeFrameAutomationClient { 81 class MockAutomationClient: public ChromeFrameAutomationClient {
82 public: 82 public:
83 MOCK_METHOD2(Initialize, bool(ChromeFrameDelegate*, 83 MOCK_METHOD2(Initialize, bool(ChromeFrameDelegate*,
84 const ChromeFrameLaunchParams&)); 84 ChromeFrameLaunchParams*));
85 MOCK_METHOD1(SetEnableExtensionAutomation, 85 MOCK_METHOD1(SetEnableExtensionAutomation,
86 void(const std::vector<std::string>&)); // NOLINT 86 void(const std::vector<std::string>&)); // NOLINT
87 }; 87 };
88 88
89 class MockProxyService: public NpProxyService { 89 class MockProxyService: public NpProxyService {
90 public: 90 public:
91 MOCK_METHOD2(Initialize, bool(NPP instance, ChromeFrameAutomationClient*)); 91 MOCK_METHOD2(Initialize, bool(NPP instance, ChromeFrameAutomationClient*));
92 }; 92 };
93 93
94 namespace {
95
96 MATCHER_P4(LaunchParamEq, version_check, extra, incognito, widget,
97 "Basic check for ChromeFrameLaunchParams") {
98 return arg->version_check() == version_check &&
99 arg->extra_arguments().compare(extra) == 0 &&
100 arg->incognito() == incognito,
101 arg->widget_mode() == widget;
102 }
103 }
94 104
95 // Test fixture to allow testing the privileged NPAPI APIs 105 // Test fixture to allow testing the privileged NPAPI APIs
96 class TestNPAPIPrivilegedApi: public ::testing::Test { 106 class TestNPAPIPrivilegedApi: public ::testing::Test {
97 public: 107 public:
98 virtual void SetUp() { 108 virtual void SetUp() {
99 memset(&instance, 0, sizeof(instance)); 109 memset(&instance, 0, sizeof(instance));
100 110
101 // Gets owned & destroyed by mock_api (in the 111 // Gets owned & destroyed by mock_api (in the
102 // ChromeFramePlugin<T>::Uninitialize() function). 112 // ChromeFramePlugin<T>::Uninitialize() function).
103 mock_automation = new MockAutomationClient; 113 mock_automation = new MockAutomationClient;
(...skipping 14 matching lines...) Expand all
118 const std::wstring& extra_args) { 128 const std::wstring& extra_args) {
119 EXPECT_CALL(mock_api, GetLocation()) 129 EXPECT_CALL(mock_api, GetLocation())
120 .WillOnce(Return(std::string("http://www.google.com"))); 130 .WillOnce(Return(std::string("http://www.google.com")));
121 EXPECT_CALL(mock_api, CreatePrefService()) 131 EXPECT_CALL(mock_api, CreatePrefService())
122 .WillOnce(Return(mock_proxy)); 132 .WillOnce(Return(mock_proxy));
123 EXPECT_CALL(mock_api, GetBrowserIncognitoMode()) 133 EXPECT_CALL(mock_api, GetBrowserIncognitoMode())
124 .WillOnce(Return(is_incognito)); 134 .WillOnce(Return(is_incognito));
125 135
126 EXPECT_CALL(*mock_proxy, Initialize(_, _)).WillRepeatedly(Return(false)); 136 EXPECT_CALL(*mock_proxy, Initialize(_, _)).WillRepeatedly(Return(false));
127 137
138 scoped_refptr<ChromeFrameLaunchParams> launch_params(
139 new ChromeFrameLaunchParams(GURL(), GURL(), FilePath(), profile_name,
140 extra_args, is_incognito, true));
141
128 EXPECT_CALL(*mock_automation, 142 EXPECT_CALL(*mock_automation,
129 Initialize(_, AllOf( 143 Initialize(_, LaunchParamEq(true, extra_args, is_incognito, true)))
130 Field(&ChromeFrameLaunchParams::perform_version_check, true),
131 Field(&ChromeFrameLaunchParams::extra_chrome_arguments,
132 StrEq(extra_args)),
133 Field(&ChromeFrameLaunchParams::incognito_mode, is_incognito),
134 Field(&ChromeFrameLaunchParams::is_widget_mode, true))))
135 .WillOnce(Return(true)); 144 .WillOnce(Return(true));
136 145
137 if (expect_privilege_check) { 146 if (expect_privilege_check) {
138 EXPECT_CALL(mock_priv, IsFireFoxPrivilegedInvocation(_)) 147 EXPECT_CALL(mock_priv, IsFireFoxPrivilegedInvocation(_))
139 .WillOnce(Return(is_privileged)); 148 .WillOnce(Return(is_privileged));
140 } else { 149 } else {
141 EXPECT_CALL(mock_priv, IsFireFoxPrivilegedInvocation(_)) 150 EXPECT_CALL(mock_priv, IsFireFoxPrivilegedInvocation(_))
142 .Times(0); // Fail if privilege check invoked. 151 .Times(0); // Fail if privilege check invoked.
143 } 152 }
144 } 153 }
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 // And fething it should return the value we just set. 556 // And fething it should return the value we just set.
548 VOID_TO_NPVARIANT(var); 557 VOID_TO_NPVARIANT(var);
549 EXPECT_TRUE(mock_api.GetProperty(kOnPrivateMessageId, &var)); 558 EXPECT_TRUE(mock_api.GetProperty(kOnPrivateMessageId, &var));
550 EXPECT_TRUE(NPVARIANT_IS_OBJECT(var)); 559 EXPECT_TRUE(NPVARIANT_IS_OBJECT(var));
551 EXPECT_EQ(kMockNPObject, NPVARIANT_TO_OBJECT(var)); 560 EXPECT_EQ(kMockNPObject, NPVARIANT_TO_OBJECT(var));
552 561
553 mock_api.Uninitialize(); 562 mock_api.Uninitialize();
554 } 563 }
555 564
556 // TODO(siggi): test invoking postPrivateMessage. 565 // TODO(siggi): test invoking postPrivateMessage.
566
OLDNEW
« no previous file with comments | « chrome_frame/chrome_frame_automation.cc ('k') | chrome_frame/chrome_frame_plugin.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698