Bug 92964

Summary: [EFL] Change return value of battey level
Product: WebKit Reporter: Kihong Kwon <kihong.kwon>
Component: WebKit EFLAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: gyuyoung.kim, hausmann, lucas.de.marchi, rakuco, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
URL: http://www.w3.org/TR/battery-status/#idl-def-BatteryManager
Bug Depends on:    
Bug Blocks: 92839    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Description Kihong Kwon 2012-08-02 02:36:16 PDT
Battery level is defined like below, in the Battery Status API spec.
------------------------------------------------------------
level of type double, readonly
Represents the current battery level scaled from 0 to 1.0.
No exceptions.
------------------------------------------------------------
But EFL battery returns 0 ~ 100 level.

Therefore we need to fix this to 0 ~ 1.0.
Comment 1 Kihong Kwon 2012-08-02 03:34:41 PDT
Created attachment 156027 [details]
Patch
Comment 2 Ryuan Choi 2012-08-02 03:50:00 PDT
Comment on attachment 156027 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=156027&action=review

> Source/WebCore/platform/efl/BatteryProviderEfl.cpp:165
>          levelChanged = true;
>      level = property->val.d;
>  
> -    WTF::RefPtr<BatteryStatus> batteryStatus = BatteryStatus::create(charging, chargingTime, dischargingTime, level);
> +    WTF::RefPtr<BatteryStatus> batteryStatus = BatteryStatus::create(charging, chargingTime, dischargingTime, level / 100);

If then, should we compare with clientBatteryStatus->level() * 100 and property->val.d ?

IMO, you'd better to assign property->val.d / 100 to `level` to reduce confusion.
Comment 3 Kihong Kwon 2012-08-02 03:52:44 PDT
(In reply to comment #2)
> (From update of attachment 156027 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=156027&action=review
> 
> > Source/WebCore/platform/efl/BatteryProviderEfl.cpp:165
> >          levelChanged = true;
> >      level = property->val.d;
> >  
> > -    WTF::RefPtr<BatteryStatus> batteryStatus = BatteryStatus::create(charging, chargingTime, dischargingTime, level);
> > +    WTF::RefPtr<BatteryStatus> batteryStatus = BatteryStatus::create(charging, chargingTime, dischargingTime, level / 100);
> 
> If then, should we compare with clientBatteryStatus->level() * 100 and property->val.d ?
> 
> IMO, you'd better to assign property->val.d / 100 to `level` to reduce confusion.

You are right. It was my mistake.
Comment 4 Kihong Kwon 2012-08-02 03:54:48 PDT
Created attachment 156032 [details]
Patch
Comment 5 Ryuan Choi 2012-08-02 04:09:19 PDT
Comment on attachment 156032 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=156032&action=review

> Source/WebCore/platform/efl/BatteryProviderEfl.cpp:163
> -    if (!clientBatteryStatus || clientBatteryStatus->level() != property->val.d)
> +    if (!clientBatteryStatus || clientBatteryStatus->level() != property->val.d / 100)
>          levelChanged = true;
> -    level = property->val.d;
> +    level = property->val.d / 100;

I am not sure why you use level, local variable.

IMO, you can remove level variable or assign it before 161 line with declaration.
Comment 6 Kihong Kwon 2012-08-02 04:13:53 PDT
Created attachment 156037 [details]
Patch
Comment 7 Kihong Kwon 2012-08-02 05:39:44 PDT
Created attachment 156051 [details]
Patch
Comment 8 Ryuan Choi 2012-08-02 05:44:49 PDT
Comment on attachment 156051 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=156051&action=review

> Source/WebCore/ChangeLog:11
> +        No new tests, no behavior changed.

I think that this comment is wrong.

This patch changes behavior but we can not make automated tests for this because we can not emulate E_Ukit.

> Source/WebCore/platform/efl/BatteryProviderEfl.cpp:155
> +    double level = property->val.d / 100;

I think that property of "Percentage" is not assigned yet.
Comment 9 Kihong Kwon 2012-08-02 05:49:59 PDT
Created attachment 156053 [details]
Patch
Comment 10 WebKit Review Bot 2012-08-02 06:46:00 PDT
Comment on attachment 156053 [details]
Patch

Clearing flags on attachment: 156053

Committed r124450: <http://trac.webkit.org/changeset/124450>
Comment 11 WebKit Review Bot 2012-08-02 06:46:05 PDT
All reviewed patches have been landed.  Closing bug.