Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stdio.h> | 5 #include <stdio.h> |
| 6 | 6 |
| 7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "chrome/installer/gcapi/gcapi.h" | 9 #include "chrome/installer/gcapi/gcapi.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 void call_statically() { | 12 void call_statically() { |
| 13 DWORD reason = 0; | 13 DWORD reason = 0; |
| 14 BOOL result_flag_on = FALSE; | 14 BOOL result_flag_on = FALSE; |
| 15 BOOL result_flag_off = FALSE; | 15 BOOL result_flag_off = FALSE; |
| 16 | 16 |
| 17 // running this twice verifies that the first call does not set | 17 // running this twice verifies that the first call does not set |
| 18 // a flag that would make the second fail. Thus, the results | 18 // a flag that would make the second fail. Thus, the results |
| 19 // of the two calls should be the same (no state should have changed) | 19 // of the two calls should be the same (no state should have changed) |
| 20 result_flag_off = GoogleChromeCompatibilityCheck( | 20 result_flag_off = GoogleChromeCompatibilityCheck( |
| 21 FALSE, GCAPI_INVOKED_STANDARD_SHELL, &reason); | 21 FALSE, GCAPI_INVOKED_STANDARD_SHELL, &reason); |
| 22 result_flag_on = GoogleChromeCompatibilityCheck( | 22 result_flag_on = GoogleChromeCompatibilityCheck( |
| 23 TRUE, GCAPI_INVOKED_STANDARD_SHELL, &reason); | 23 TRUE, GCAPI_INVOKED_STANDARD_SHELL, &reason); |
| 24 | 24 |
| 25 if (result_flag_off != result_flag_on) | 25 if (result_flag_off != result_flag_on) |
| 26 printf("Registry key flag is not being set properly."); | 26 printf("Registry key flag is not being set properly."); |
| 27 | 27 |
| 28 printf("Static call returned result as %ld and reason as %ld.\n", | 28 printf("Static call returned result as %d and reason as %ld.\n", |
|
scottmg
2014/09/05 17:09:40
bah, I even looked up what BOOL was, saw that it w
| |
| 29 result_flag_on, reason); | 29 result_flag_on, reason); |
| 30 } | 30 } |
| 31 | 31 |
| 32 void call_dynamically() { | 32 void call_dynamically() { |
| 33 HMODULE module = LoadLibrary(L"gcapi_dll.dll"); | 33 HMODULE module = LoadLibrary(L"gcapi_dll.dll"); |
| 34 if (module == NULL) { | 34 if (module == NULL) { |
| 35 printf("Couldn't load gcapi_dll.dll.\n"); | 35 printf("Couldn't load gcapi_dll.dll.\n"); |
| 36 return; | 36 return; |
| 37 } | 37 } |
| 38 | 38 |
| 39 GCCC_CompatibilityCheck gccfn = (GCCC_CompatibilityCheck) GetProcAddress( | 39 GCCC_CompatibilityCheck gccfn = (GCCC_CompatibilityCheck) GetProcAddress( |
| 40 module, "GoogleChromeCompatibilityCheck"); | 40 module, "GoogleChromeCompatibilityCheck"); |
| 41 if (gccfn != NULL) { | 41 if (gccfn != NULL) { |
| 42 DWORD reason = 0; | 42 DWORD reason = 0; |
| 43 | 43 |
| 44 // running this twice verifies that the first call does not set | 44 // running this twice verifies that the first call does not set |
| 45 // a flag that would make the second fail. Thus, the results | 45 // a flag that would make the second fail. Thus, the results |
| 46 // of the two calls should be the same (no state should have changed) | 46 // of the two calls should be the same (no state should have changed) |
| 47 BOOL result_flag_off = gccfn(FALSE, GCAPI_INVOKED_STANDARD_SHELL, &reason); | 47 BOOL result_flag_off = gccfn(FALSE, GCAPI_INVOKED_STANDARD_SHELL, &reason); |
| 48 BOOL result_flag_on = gccfn(TRUE, GCAPI_INVOKED_STANDARD_SHELL, &reason); | 48 BOOL result_flag_on = gccfn(TRUE, GCAPI_INVOKED_STANDARD_SHELL, &reason); |
| 49 | 49 |
| 50 if (result_flag_off != result_flag_on) | 50 if (result_flag_off != result_flag_on) |
| 51 printf("Registry key flag is not being set properly."); | 51 printf("Registry key flag is not being set properly."); |
| 52 | 52 |
| 53 printf("Dynamic call returned result as %d and reason as %d.\n", | 53 printf("Dynamic call returned result as %d and reason as %ld.\n", |
| 54 result_flag_on, reason); | 54 result_flag_on, reason); |
| 55 } else { | 55 } else { |
| 56 printf("Couldn't find GoogleChromeCompatibilityCheck() in gcapi_dll.\n"); | 56 printf("Couldn't find GoogleChromeCompatibilityCheck() in gcapi_dll.\n"); |
| 57 } | 57 } |
| 58 FreeLibrary(module); | 58 FreeLibrary(module); |
| 59 } | 59 } |
| 60 | 60 |
| 61 const char kManualLaunchTests[] = "launch-chrome"; | 61 const char kManualLaunchTests[] = "launch-chrome"; |
| 62 | 62 |
| 63 int main(int argc, char* argv[]) { | 63 int main(int argc, char* argv[]) { |
| 64 base::AtExitManager exit_manager; | 64 base::AtExitManager exit_manager; |
| 65 CommandLine::Init(argc, argv); | 65 CommandLine::Init(argc, argv); |
| 66 | 66 |
| 67 testing::InitGoogleTest(&argc, argv); | 67 testing::InitGoogleTest(&argc, argv); |
| 68 RUN_ALL_TESTS(); | 68 RUN_ALL_TESTS(); |
| 69 | 69 |
| 70 if (CommandLine::ForCurrentProcess()->HasSwitch(kManualLaunchTests)) { | 70 if (CommandLine::ForCurrentProcess()->HasSwitch(kManualLaunchTests)) { |
| 71 call_dynamically(); | 71 call_dynamically(); |
| 72 call_statically(); | 72 call_statically(); |
| 73 printf("LaunchChrome returned %d.\n", LaunchGoogleChrome()); | 73 printf("LaunchChrome returned %d.\n", LaunchGoogleChrome()); |
| 74 } | 74 } |
| 75 } | 75 } |
| OLD | NEW |