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

Side by Side Diff: webkit/tools/test_shell/mac/layout_test_helper.mm

Issue 10694063: Remove layout_test_helper from webkit/tools/test_shell. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 | « no previous file | webkit/tools/test_shell/test_shell.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #import <AppKit/AppKit.h>
6 #include <signal.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9
10 // This is a simple helper app that changes the color sync profile to the
11 // generic profile and back when done. This program is managed by the layout
12 // test script, so it can do the job for multiple test shells while they are
13 // running layout tests.
14
15 static CMProfileRef gUsersColorProfile = NULL;
16
17 static void SaveCurrentColorProfile(void) {
18 CGDirectDisplayID displayID = CGMainDisplayID();
19 CMProfileRef previousProfile;
20 CMError error = CMGetProfileByAVID((UInt32)displayID, &previousProfile);
21 if (error) {
22 NSLog(@"failed to get the current color profile, pixmaps won't match. "
23 @"Error: %d", (int)error);
24 } else {
25 gUsersColorProfile = previousProfile;
26 }
27 }
28
29 static void InstallLayoutTestColorProfile(void) {
30 // To make sure we get consistent colors (not dependent on the Main display),
31 // we force the generic rgb color profile. This cases a change the user can
32 // see.
33
34 CGDirectDisplayID displayID = CGMainDisplayID();
35 NSColorSpace *genericSpace = [NSColorSpace genericRGBColorSpace];
36 CMProfileRef genericProfile = (CMProfileRef)[genericSpace colorSyncProfile];
37 CMError error = CMSetProfileByAVID((UInt32)displayID, genericProfile);
38 if (error) {
39 NSLog(@"failed install the generic color profile, pixmaps won't match. "
40 @"Error: %d", (int)error);
41 }
42 }
43
44 static void RestoreUsersColorProfile(void) {
45 if (gUsersColorProfile) {
46 CGDirectDisplayID displayID = CGMainDisplayID();
47 CMError error = CMSetProfileByAVID((UInt32)displayID, gUsersColorProfile);
48 CMCloseProfile(gUsersColorProfile);
49 if (error) {
50 NSLog(@"Failed to restore color profile, use System Preferences -> "
51 @"Displays -> Color to reset. Error: %d", (int)error);
52 }
53 gUsersColorProfile = NULL;
54 }
55 }
56
57 static void SimpleSignalHandler(int sig) {
58 // Try to restore the color profile and try to go down cleanly
59 RestoreUsersColorProfile();
60 exit(128 + sig);
61 }
62
63 int main(int argc, char *argv[]) {
64 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
65
66 // Hooks the ways we might get told to clean up...
67 signal(SIGINT, SimpleSignalHandler);
68 signal(SIGHUP, SimpleSignalHandler);
69 signal(SIGTERM, SimpleSignalHandler);
70
71 // Save off the current profile, and then install the layout test profile.
72 SaveCurrentColorProfile();
73 InstallLayoutTestColorProfile();
74
75 // Let the script know we're ready
76 printf("ready\n");
77 fflush(stdout);
78
79 // Wait for any key (or signal)
80 getchar();
81
82 // Restore the profile
83 RestoreUsersColorProfile();
84
85 [pool release];
86 return 0;
87 }
OLDNEW
« no previous file with comments | « no previous file | webkit/tools/test_shell/test_shell.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698