⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pwrprof.c

📁 winNT技术操作系统,国外开放的原代码和LIUX一样
💻 C
📖 第 1 页 / 共 4 页
字号:
   ret = SetActivePwrScheme(g_ActivePwrScheme, 0, 0);
   ok(ret, "Warning: failed to restore old active power scheme %d\n", (UINT)g_ActivePwrScheme);

}

void test_GetPwrCapabilities(void)
{
   SYSTEM_POWER_CAPABILITIES spc;
   BOOLEAN ret;

   ret = GetPwrCapabilities(0);
   ok(!ret, "function was expected to fail\n");
   if (!ret)
   {
      ok(GetLastError() == ERROR_INVALID_PARAMETER,"function was expectet to return ERROR_INVALID_PARAMETER, but returns: %x\n",(UINT)GetLastError());
   }
   ret = GetPwrCapabilities(&spc);
   ok(ret, "function was expected to succeed, error %x\n",(UINT)GetLastError());
}

void test_GetPwrDiskSpindownRange(void)
{
   DWORD retval;
   UINT min = 0;
   UINT max = 0;

   /*
    *  invalid parameter checks
    */

   retval = GetPwrDiskSpindownRange(NULL, NULL);
   ok(!retval, "function was expected to fail\n");
   ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected error ERROR_INVALID_PARAMETER but got %x\n", (UINT)GetLastError());

   retval = GetPwrDiskSpindownRange(&max, NULL);
   ok(!retval, "function was expected to fail\n");
   ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected error ERROR_INVALID_PARAMETER but got %x\n", (UINT)GetLastError());

   retval = GetPwrDiskSpindownRange(NULL, &min);
   ok(!retval, "function was expected to fail\n");
   ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected error ERROR_INVALID_PARAMETER but got %x\n", (UINT)GetLastError());

   /*
    * read disk spindown range
    */

   retval = GetPwrDiskSpindownRange(&max, &min);
   ok(retval, "function was expected to succeed error %x\n",(UINT)GetLastError());
   ok(min <= max, "range mismatch min %d max %d\n",min, max);
}

void test_IsAdminOverrideActive(void)
{
   ADMINISTRATOR_POWER_POLICY app;
   BOOLEAN ret;

   ret = IsAdminOverrideActive(0);
   ok(!ret, "function was expected to fail, error %x\n",(UINT)GetLastError());

   ret = IsAdminOverrideActive(&app);
   ok(!ret, "function was expected to fail, error %x\n",(UINT)GetLastError());

   app.MinSleep = 0;
   app.MaxSleep = 0;
   app.MinVideoTimeout = 0;
   app.MaxVideoTimeout = 0;
   app.MinSpindownTimeout = 0;
   app.MaxSpindownTimeout = 0;

   ret = IsAdminOverrideActive(&app);
   ok(!ret, "function was expected to fail, error %x\n",(UINT)GetLastError());

   app.MinSleep = 1;
   app.MaxSleep = 2;
   app.MinVideoTimeout = 3;
   app.MaxVideoTimeout = 4;
   app.MinSpindownTimeout = 5;
   app.MaxSpindownTimeout = 6;

   ret = IsAdminOverrideActive(&app);
   ok(!ret, "function was expected to fail, error %x\n",(UINT)GetLastError());

}

void test_IsPwrHibernateAllowed(void)
{
/*
        BOOLEAN ret;

        ret = IsPwrHibernateAllowed();
        ok(!ret, "function was expected to fail, error %x\n",(UINT)GetLastError());
 */
}

void test_IsPwrShutdownAllowed(void)
{
/*
        BOOLEAN ret;

        ret = IsPwrShutdownAllowed();
        ok(ret, "function was expected to succeed, error %x\n",(UINT)GetLastError());
 */
}

void test_IsPwrSuspendAllowed(void)
{
/*
        BOOLEAN ret;

        ret = IsPwrSuspendAllowed();
        ok(ret, "function was expected to succed, error %x\n",(UINT)GetLastError());
 */
}

void test_ReadGlobalPwrPolicy(void)
{
   GLOBAL_POWER_POLICY gpp;
   BOOLEAN ret;

   ret = ReadGlobalPwrPolicy(&gpp);
   ok(ret, "function was expected to succeed, error %x\n",(UINT)GetLastError());
   ok(gpp.mach.Revision  == 1,"Global Mach Revision was expected to be 1 got %i",(UINT)gpp.mach.Revision);
   ok(gpp.user.Revision  == 1,"Global User Revision was expected to be 1 got %i",(UINT)gpp.mach.Revision);



}

void test_ReadProcessorPwrScheme(void)
{
   MACHINE_PROCESSOR_POWER_POLICY mppp;
   BOOLEAN ret;
   UINT i = 0;
   DWORD err;

   do
   {
      RtlZeroMemory(&mppp, sizeof(MACHINE_PROCESSOR_POWER_POLICY));
      ret = ReadProcessorPwrScheme(i,&mppp);
      if (ret)
      {
         ok(mppp.Revision == 1,"Main Revision was expected to be 1 got %i",(UINT)mppp.Revision);
         ok(mppp.ProcessorPolicyAc.Revision == 1,"PowerAC Revision was expected to be 1 got %i",(UINT)mppp.ProcessorPolicyAc.Revision);
         ok(mppp.ProcessorPolicyDc.Revision == 1,"PowerDC Revision was expected to be 1 got %i",(UINT)mppp.ProcessorPolicyDc.Revision);
      }
      else
      {
         err = GetLastError();
         ok(err == 0,"Failed Error %x\n",(UINT)err);
         return;
      }
      i++;
      if (i == g_NumPwrSchemes)
         return;
   } while (TRUE);

}

void test_ReadPwrScheme(void)
{
   DWORD retval;

   /*
    * read power scheme with null pointer -> crashs on Windows XP SP2
    */
   //retval = ReadPwrScheme(0, NULL);
   //ok(!retval, "function was expected to fail\n");
   //ok(GetLastError() == STATUS_INVALID_PARAMETER, "expected error ... but got %x\n", GetLastError());

   /*
    *  read a power scheme with an invalid index, leads to the creation of the key
    *  -> corrupts power scheme enumeration
    */
   //retval = ReadPwrScheme(0xFFFFFFFF, &powerPolicy);
   //ok(!retval, "function was expected to fail\n");
   //ok(GetLastError() == ERROR_ACCESS_DENIED, "expected error ERROR_ACCESS_DENIED but got %x\n", GetLastError());

   /*
    * read current active power scheme
    */

   retval = ReadPwrScheme(g_ActivePwrScheme, &g_PowerPolicy);
   ok(retval, "function was expected to succeed error %x\n",(UINT)GetLastError());

}

void test_SetSuspendState(void)
{
//	SetSuspendState(FALSE,FALSE,FALSE)
}

void test_ValidatePowerPolicies(void)
{
   GLOBAL_POWER_POLICY gpp;
   POWER_POLICY pp;
   BOOLEAN ret;

   SetLastError(0);
   ret = ValidatePowerPolicies(0,0);
   ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());

   ret = ValidatePowerPolicies(&gpp,0);
   ok(!ret, "function was expected to fail return %i\n",(UINT)ret);
   ok(GetLastError() == ERROR_REVISION_MISMATCH,"function was expected to fail with ERROR_REVISION_MISMATCH(%i,%i), but error :%i\n",(UINT)gpp.user.Revision,(UINT)gpp.mach.Revision,(UINT)GetLastError());

   ret = ValidatePowerPolicies(0,&pp);
   ok(!ret, "function was expected to fail return %i\n",(UINT)ret);
   ok(GetLastError() == ERROR_REVISION_MISMATCH,"function was expected to fail with ERROR_REVISION_MISMATCH, but error :%i\n",(UINT)GetLastError());

   ret = ValidatePowerPolicies(&gpp,&pp);
   ok(!ret, "function was expected to fail return %i\n",(UINT)ret);
   ok(GetLastError() == ERROR_REVISION_MISMATCH,"function was expected to fail with ERROR_REVISION_MISMATCH, but error :%i\n",(UINT)GetLastError());

   gpp.user.Revision = 1;
   gpp.mach.Revision = 1;

   ret = ValidatePowerPolicies(&gpp,0);
   ok(!ret, "function was expected to fail return %i\n",(UINT)ret);
   ok(GetLastError() == ERROR_INVALID_DATA,"function was expected to fail with ERROR_INVALID_DATA, but error :%i\n",(UINT)GetLastError());

   gpp.mach.LidOpenWakeAc = PowerSystemWorking;
   gpp.mach.LidOpenWakeDc = PowerSystemWorking;

   ret = ValidatePowerPolicies(&gpp,0);
   ok(!ret, "function was expected to fail return %i\n",(UINT)ret);
   ok(GetLastError() == ERROR_INVALID_DATA,"function was expected to fail with ERROR_INVALID_DATA, but error :%i\n",(UINT)GetLastError());

   gpp.user.PowerButtonAc.Action = PowerActionNone;
   gpp.user.PowerButtonDc.Action = PowerActionNone;
   gpp.user.SleepButtonAc.Action = PowerActionNone;
   gpp.user.SleepButtonDc.Action = PowerActionNone;
   gpp.user.LidCloseAc.Action = PowerActionNone;
   gpp.user.LidCloseDc.Action = PowerActionNone;

   gpp.user.DischargePolicy[0].Enable=FALSE;
   gpp.user.DischargePolicy[1].Enable=FALSE;
   gpp.user.DischargePolicy[2].Enable=FALSE;
   gpp.user.DischargePolicy[3].Enable=FALSE;
   gpp.user.DischargePolicy[4].Enable=FALSE;
   ret = ValidatePowerPolicies(&gpp,0);
   ok(ret, "function was expected to succeed return %i\n",(UINT)GetLastError());
   if (!ret)
   {
      ok(GetLastError() == ERROR_INVALID_DATA,"function was expected to fail with ERROR_INVALID_DATA, but error :%i\n",(UINT)GetLastError());
   }

   pp.user.Revision = 1;
   pp.mach.Revision = 1;

   ret = ValidatePowerPolicies(0,&pp);
   ok(!ret, "function was expected to fail return %i\n",(UINT)ret);
   ok(GetLastError() == ERROR_INVALID_DATA || GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE or ERROR_INVALID_DATA, but error :%i\n",(UINT)GetLastError());

   pp.mach.MinSleepAc = PowerSystemWorking;
   pp.mach.MinSleepDc = PowerSystemWorking;
   pp.mach.ReducedLatencySleepAc = PowerSystemWorking;
   pp.mach.ReducedLatencySleepDc = PowerSystemWorking;
   pp.mach.OverThrottledAc.Action = PowerActionNone;
   pp.mach.OverThrottledDc.Action = PowerActionNone;

   pp.user.IdleAc.Action = PowerActionWarmEject+1;
   pp.user.IdleDc.Action = PowerActionNone-1;
   pp.user.MaxSleepAc = PowerSystemMaximum+1;
   pp.user.MaxSleepDc = PowerSystemUnspecified;

   ret = ValidatePowerPolicies(0,&pp);
   ok(!ret, "function was expected to fail return %i\n",(UINT)GetLastError());
   if (!ret)
   {
      ok(GetLastError() == ERROR_INVALID_DATA,"function was expected to fail with ERROR_INVALID_DATA, but error :%i\n",(UINT)GetLastError());
   }

   pp.user.IdleAc.Action = PowerActionNone;
   pp.user.IdleDc.Action = PowerActionNone;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -