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

Side by Side Diff: chrome_frame/test/proxy_factory_mock.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/test/proxy_factory_mock.h ('k') | chrome_frame/test/ui_test.cc » ('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) 2006-2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-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 #include "base/waitable_event.h" 4 #include "base/waitable_event.h"
5 #include "chrome_frame/test/proxy_factory_mock.h" 5 #include "chrome_frame/test/proxy_factory_mock.h"
6 6
7 #define GMOCK_MUTANT_INCLUDE_LATE_OBJECT_BINDING 7 #define GMOCK_MUTANT_INCLUDE_LATE_OBJECT_BINDING
8 #include "testing/gmock_mutant.h" 8 #include "testing/gmock_mutant.h"
9 9
10 using testing::CreateFunctor; 10 using testing::CreateFunctor;
11 using testing::_; 11 using testing::_;
12 12
13 DISABLE_RUNNABLE_METHOD_REFCOUNT(MockProxyFactory); 13 DISABLE_RUNNABLE_METHOD_REFCOUNT(MockProxyFactory);
14 14
15 TEST(ProxyFactoryTest, CreateDestroy) { 15 TEST(ProxyFactoryTest, CreateDestroy) {
16 ProxyFactory f; 16 ProxyFactory f;
17 LaunchDelegateMock d; 17 LaunchDelegateMock d;
18 EXPECT_CALL(d, LaunchComplete(testing::NotNull(), testing::_)).Times(1); 18 EXPECT_CALL(d, LaunchComplete(testing::NotNull(), testing::_)).Times(1);
19 19
20 ChromeFrameLaunchParams params; 20 GURL empty;
21 params.automation_server_launch_timeout = 0; 21 FilePath profile_path;
22 params.profile_name = L"Adam.N.Epilinter"; 22 scoped_refptr<ChromeFrameLaunchParams> params(
23 params.extra_chrome_arguments = L""; 23 new ChromeFrameLaunchParams(empty, empty, profile_path,
24 params.perform_version_check = false; 24 L"Adam.N.Epilinter", L"", false, false));
25 params.incognito_mode = false; 25 params->set_launch_timeout(0);
26 params->set_version_check(false);
26 27
27 void* id = NULL; 28 void* id = NULL;
28 f.GetAutomationServer(&d, params, &id); 29 f.GetAutomationServer(&d, params, &id);
29 f.ReleaseAutomationServer(id); 30 f.ReleaseAutomationServer(id, &d);
30 } 31 }
31 32
32 TEST(ProxyFactoryTest, CreateSameProfile) { 33 TEST(ProxyFactoryTest, CreateSameProfile) {
33 ProxyFactory f; 34 ProxyFactory f;
34 LaunchDelegateMock d; 35 LaunchDelegateMock d;
35 EXPECT_CALL(d, LaunchComplete(testing::NotNull(), testing::_)).Times(2); 36 LaunchDelegateMock d2;
37 EXPECT_CALL(d, LaunchComplete(testing::NotNull(), testing::_)).Times(1);
38 EXPECT_CALL(d2, LaunchComplete(testing::NotNull(), testing::_)).Times(1);
36 39
37 ChromeFrameLaunchParams params; 40 GURL empty;
38 params.automation_server_launch_timeout = 0; 41 FilePath profile_path;
39 params.profile_name = L"Dr. Gratiano Forbeson"; 42 scoped_refptr<ChromeFrameLaunchParams> params(
40 params.extra_chrome_arguments = L""; 43 new ChromeFrameLaunchParams(empty, empty, profile_path,
41 params.perform_version_check = false; 44 L"Dr. Gratiano Forbeson", L"", false, false));
42 params.incognito_mode = false; 45 params->set_launch_timeout(0);
46 params->set_version_check(false);
43 47
44 void* i1 = NULL; 48 void* i1 = NULL;
45 void* i2 = NULL; 49 void* i2 = NULL;
46 50
47 f.GetAutomationServer(&d, params, &i1); 51 f.GetAutomationServer(&d, params, &i1);
48 f.GetAutomationServer(&d, params, &i2); 52 f.GetAutomationServer(&d2, params, &i2);
49 53
50 EXPECT_EQ(i1, i2); 54 EXPECT_EQ(i1, i2);
51 f.ReleaseAutomationServer(i2); 55 f.ReleaseAutomationServer(i2, &d2);
52 f.ReleaseAutomationServer(i1); 56 f.ReleaseAutomationServer(i1, &d);
53 } 57 }
54 58
55 TEST(ProxyFactoryTest, CreateDifferentProfiles) { 59 TEST(ProxyFactoryTest, CreateDifferentProfiles) {
56 ProxyFactory f; 60 ProxyFactory f;
57 LaunchDelegateMock d; 61 LaunchDelegateMock d;
58 EXPECT_CALL(d, LaunchComplete(testing::NotNull(), testing::_)).Times(2); 62 EXPECT_CALL(d, LaunchComplete(testing::NotNull(), testing::_)).Times(2);
59 63
60 ChromeFrameLaunchParams params1; 64 GURL empty;
61 params1.automation_server_launch_timeout = 0; 65 FilePath profile_path;
62 params1.profile_name = L"Adam.N.Epilinter"; 66 scoped_refptr<ChromeFrameLaunchParams> params1(
63 params1.extra_chrome_arguments = L""; 67 new ChromeFrameLaunchParams(empty, empty, profile_path,
64 params1.perform_version_check = false; 68 L"Adam.N.Epilinter", L"", false, false));
65 params1.incognito_mode = false; 69 params1->set_launch_timeout(0);
70 params1->set_version_check(false);
66 71
67 ChromeFrameLaunchParams params2; 72 scoped_refptr<ChromeFrameLaunchParams> params2(
68 params2.automation_server_launch_timeout = 0; 73 new ChromeFrameLaunchParams(empty, empty, profile_path,
69 params2.profile_name = L"Dr. Gratiano Forbeson"; 74 L"Dr. Gratiano Forbeson", L"", false, false));
70 params2.extra_chrome_arguments = L""; 75 params2->set_launch_timeout(0);
71 params2.perform_version_check = false; 76 params2->set_version_check(false);
72 params2.incognito_mode = false;
73 77
74 void* i1 = NULL; 78 void* i1 = NULL;
75 void* i2 = NULL; 79 void* i2 = NULL;
76 80
77 f.GetAutomationServer(&d, params1, &i1); 81 f.GetAutomationServer(&d, params1, &i1);
78 f.GetAutomationServer(&d, params2, &i2); 82 f.GetAutomationServer(&d, params2, &i2);
79 83
80 EXPECT_NE(i1, i2); 84 EXPECT_NE(i1, i2);
81 f.ReleaseAutomationServer(i2); 85 f.ReleaseAutomationServer(i2, &d);
82 f.ReleaseAutomationServer(i1); 86 f.ReleaseAutomationServer(i1, &d);
83 } 87 }
84 88
85 TEST(ProxyFactoryTest, FastCreateDestroy) { 89 TEST(ProxyFactoryTest, FastCreateDestroy) {
86 ProxyFactory f; 90 ProxyFactory f;
87 LaunchDelegateMock* d1 = new LaunchDelegateMock(); 91 LaunchDelegateMock* d1 = new LaunchDelegateMock();
88 LaunchDelegateMock* d2 = new LaunchDelegateMock(); 92 LaunchDelegateMock* d2 = new LaunchDelegateMock();
89 93
90 ChromeFrameLaunchParams params; 94 GURL empty;
91 params.automation_server_launch_timeout = 10000; 95 FilePath profile_path;
92 params.profile_name = L"Dr. Gratiano Forbeson"; 96 scoped_refptr<ChromeFrameLaunchParams> params(
93 params.extra_chrome_arguments = L""; 97 new ChromeFrameLaunchParams(empty, empty, profile_path,
94 params.perform_version_check = false; 98 L"Dr. Gratiano Forbeson", L"", false, false));
95 params.incognito_mode = false; 99 params->set_launch_timeout(10000);
100 params->set_version_check(false);
96 101
97 void* i1 = NULL; 102 void* i1 = NULL;
98 base::WaitableEvent launched(true, false); 103 base::WaitableEvent launched(true, false);
99 EXPECT_CALL(*d1, LaunchComplete(testing::NotNull(), AUTOMATION_SUCCESS)) 104 EXPECT_CALL(*d1, LaunchComplete(testing::NotNull(), AUTOMATION_SUCCESS))
100 .Times(1)
101 .WillOnce(testing::InvokeWithoutArgs(&launched, 105 .WillOnce(testing::InvokeWithoutArgs(&launched,
102 &base::WaitableEvent::Signal)); 106 &base::WaitableEvent::Signal));
103 f.GetAutomationServer(d1, params, &i1); 107 f.GetAutomationServer(d1, params, &i1);
104 // Wait for launch 108 // Wait for launch
105 ASSERT_TRUE(launched.TimedWait(base::TimeDelta::FromSeconds(10))); 109 ASSERT_TRUE(launched.TimedWait(base::TimeDelta::FromSeconds(10)));
106 110
107 // Expect second launch to succeed too 111 // Expect second launch to succeed too
108 EXPECT_CALL(*d2, LaunchComplete(testing::NotNull(), AUTOMATION_SUCCESS)) 112 EXPECT_CALL(*d2, LaunchComplete(testing::NotNull(), AUTOMATION_SUCCESS))
109 .Times(1); 113 .Times(1);
110 114
111 // Boost thread priority so we call ReleaseAutomationServer before 115 // Boost thread priority so we call ReleaseAutomationServer before
112 // LaunchComplete callback have a chance to be executed. 116 // LaunchComplete callback have a chance to be executed.
113 ::SetThreadPriority(::GetCurrentThread(), THREAD_PRIORITY_HIGHEST); 117 ::SetThreadPriority(::GetCurrentThread(), THREAD_PRIORITY_HIGHEST);
114 void* i2 = NULL; 118 void* i2 = NULL;
115 f.GetAutomationServer(d2, params, &i2); 119 f.GetAutomationServer(d2, params, &i2);
116 EXPECT_EQ(i1, i2); 120 EXPECT_EQ(i1, i2);
117 f.ReleaseAutomationServer(i2); 121 f.ReleaseAutomationServer(i2, d2);
118 delete d2; 122 delete d2;
119 123
120 ::SetThreadPriority(::GetCurrentThread(), THREAD_PRIORITY_NORMAL); 124 ::SetThreadPriority(::GetCurrentThread(), THREAD_PRIORITY_NORMAL);
121 f.ReleaseAutomationServer(i1); 125 f.ReleaseAutomationServer(i1, d1);
122 delete d1; 126 delete d1;
123 } 127 }
OLDNEW
« no previous file with comments | « chrome_frame/test/proxy_factory_mock.h ('k') | chrome_frame/test/ui_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698