static int ConvertFontWeight(int w) { // Note that wxQFont_Thin is 0, so we can't have anything lighter than it. if ( TryToMap(w, wxFONTWEIGHT_INVALID, wxFONTWEIGHT_THIN, wxQFont_Thin, wxQFont_Thin) || TryToMap(w, wxFONTWEIGHT_THIN, wxFONTWEIGHT_EXTRALIGHT, wxQFont_Thin, wxQFont_ExtraLight) || TryToMap(w, wxFONTWEIGHT_EXTRALIGHT, wxFONTWEIGHT_LIGHT, wxQFont_ExtraLight, wxQFont_Light) || TryToMap(w, wxFONTWEIGHT_LIGHT, wxFONTWEIGHT_NORMAL, wxQFont_Light, wxQFont_Normal) || TryToMap(w, wxFONTWEIGHT_NORMAL, wxFONTWEIGHT_MEDIUM, wxQFont_Normal, wxQFont_Medium) || TryToMap(w, wxFONTWEIGHT_MEDIUM, wxFONTWEIGHT_SEMIBOLD, wxQFont_Medium, wxQFont_DemiBold) || TryToMap(w, wxFONTWEIGHT_SEMIBOLD, wxFONTWEIGHT_BOLD, wxQFont_DemiBold, wxQFont_Bold) || TryToMap(w, wxFONTWEIGHT_BOLD, wxFONTWEIGHT_EXTRABOLD, wxQFont_Bold, wxQFont_ExtraBold) || TryToMap(w, wxFONTWEIGHT_EXTRABOLD, wxFONTWEIGHT_HEAVY, wxQFont_ExtraBold, wxQFont_Black) || TryToMap(w, wxFONTWEIGHT_HEAVY, wxFONTWEIGHT_EXTRAHEAVY, wxQFont_Black, 99) ) { return w; } wxFAIL_MSG("invalid wxFont weight"); return wxQFont_Normal; }
int wxNativeFontInfo::GetNumericWeight() const { int w = m_qtFont.weight(); // Special case of wxQFont_Thin == 0. if ( w == wxQFont_Thin ) return wxFONTWEIGHT_THIN; if ( TryToMap(w, wxQFont_Thin, wxQFont_ExtraLight, wxFONTWEIGHT_THIN, wxFONTWEIGHT_EXTRALIGHT) || TryToMap(w, wxQFont_ExtraLight, wxQFont_Light, wxFONTWEIGHT_EXTRALIGHT, wxFONTWEIGHT_LIGHT) || TryToMap(w, wxQFont_Light, wxQFont_Normal, wxFONTWEIGHT_LIGHT, wxFONTWEIGHT_NORMAL) || TryToMap(w, wxQFont_Normal, wxQFont_Medium, wxFONTWEIGHT_NORMAL, wxFONTWEIGHT_MEDIUM) || TryToMap(w, wxQFont_Medium, wxQFont_DemiBold, wxFONTWEIGHT_MEDIUM, wxFONTWEIGHT_SEMIBOLD) || TryToMap(w, wxQFont_DemiBold, wxQFont_Bold, wxFONTWEIGHT_SEMIBOLD, wxFONTWEIGHT_BOLD) || TryToMap(w, wxQFont_Bold, wxQFont_ExtraBold, wxFONTWEIGHT_BOLD, wxFONTWEIGHT_EXTRABOLD) || TryToMap(w, wxQFont_ExtraBold, wxQFont_Black, wxFONTWEIGHT_EXTRABOLD, wxFONTWEIGHT_HEAVY) || TryToMap(w, wxQFont_Black, 99, wxFONTWEIGHT_HEAVY, wxFONTWEIGHT_EXTRAHEAVY) ) { return w; } wxFAIL_MSG( "Invalid QFont weight" ); return wxFONTWEIGHT_NORMAL; }
/* * It is the responsibility of the invoking environment to delete the * file passed as command-line argument. See the build.scons file. */ int main(int ac, char **av) { char const *test_dir_name = "/tmp/nacl_host_desc_mmap_win_test"; struct NaClHostDesc hd; int test_passed; size_t error_count; size_t ix; int opt; int num_runs = 1; int test_run; HANDLE h; int d; while (EOF != (opt = getopt(ac, av, "c:t:"))) { switch (opt) { case 'c': num_runs = atoi(optarg); break; case 't': test_dir_name = optarg; break; default: fprintf(stderr, "Usage: nacl_host_desc_mmap_win_test [-c run_count]\n" " [-t test_temp_dir]\n"); exit(1); } } NaClPlatformInit(); error_count = 0; for (test_run = 0; test_run < num_runs; ++test_run) { printf("Test run %d\n\n", test_run); for (ix = 0; ix < NACL_ARRAY_SIZE(tests); ++ix) { char test_file_name[PATH_MAX]; _snprintf_s(test_file_name, sizeof test_file_name, _TRUNCATE, "%s/f%d.%"NACL_PRIuS, test_dir_name, test_run, ix); printf("%s\n", tests[ix].test_info); printf("-- %s\n", tests[ix].file_type->file_type_description); h = CreateTestFile(test_file_name, tests[ix].file_type); if (ERROR_SUCCESS == tests[ix].expected_open_error) { if (INVALID_HANDLE_VALUE == h) { DWORD err = GetLastError(); NaClLog(LOG_ERROR, "CreateTestFile for %s failed, error %d\n", test_file_name, err); printf("FAILED\n"); ++error_count; continue; } d = _open_osfhandle((intptr_t) h, tests[ix].oflags); NaClHostDescPosixTake(&hd, d, tests[ix].posix_flags); test_passed = TryToMap(&hd, tests[ix].map_bytes, tests[ix].prot, tests[ix].map_flags, tests[ix].expected_mmap_errno); error_count += !test_passed; printf("%s\n", test_passed ? "PASSED" : "FAILED"); CHECK(0 == NaClHostDescClose(&hd)); AttemptToDeleteTestFile(test_file_name); } else { if (INVALID_HANDLE_VALUE == h) { DWORD err = GetLastError(); if (err != tests[ix].expected_open_error) { NaClLog(LOG_ERROR, "Expected CreateTestFile for %s to failed with" " error %d, but got error %d\n", test_file_name, err, tests[ix].expected_open_error); printf("FAILED\n"); ++error_count; } else { printf("PASSED (open failed)\n"); } continue; } else { NaClLog(LOG_ERROR, "Expected CreateTestFile for %s to fail with error %d," " but succeeded instead!\n", test_file_name, tests[ix].expected_open_error); (void) CloseHandle(h); AttemptToDeleteTestFile(test_file_name); printf("FAILED\n"); ++error_count; continue; } } } } printf("Total of %d error%s.\n", error_count, (error_count == 1) ? "" : "s"); NaClPlatformFini(); /* we ignore the 2^32 or 2^64 total errors case */ return (error_count > 255) ? 255 : error_count; }