Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Commit

Permalink
Merge pull request #36 from elizahale/master
Browse files Browse the repository at this point in the history
Adding Year Class 2016
  • Loading branch information
SeyelentEco authored Feb 23, 2018
2 parents 9e0489f + 3a6c910 commit 0355835
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ Mappings as of this writing (RAM is a ceiling):
| | 1.8GHz+ | 2013 |
| 2GB| | 2013 |
| 3GB| | 2014 |
| more| | 2015 |
| 5GB| | 2015 |
| more| | 2016 |

## Integration

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class YearClass {
public static final int CLASS_2013 = 2013;
public static final int CLASS_2014 = 2014;
public static final int CLASS_2015 = 2015;
public static final int CLASS_2016 = 2016;

private static final long MB = 1024 * 1024;
private static final int MHZ_IN_KHZ = 1000;
Expand Down Expand Up @@ -78,7 +79,10 @@ private static int categorizeByYear2016Method(Context c) {
if (totalRam <= 2048 * MB) {
return CLASS_2013;
}
return totalRam <= 3 * 1024 * MB ? CLASS_2014 : CLASS_2015;
if (totalRam <= 3 * 1024 * MB) {
return CLASS_2014;
}
return totalRam <= 5 * 1024 * MB ? CLASS_2015 : CLASS_2016;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,23 @@ public void testTotalRAM() {
assertEquals(YearClass.CLASS_2013, yearClass);
}

@PrepareForTest(DeviceInfo.class)
@Test
public void testGetYearCategoryS7() {
// CPU, frequency, RAM, and YearClass values from Samsung Galaxy Note8 (USA edition).
int yearClass = getYearClass(8, 2350000, 6144L * 1024 * 1024);
assertEquals(YearClass.CLASS_2016, yearClass);
}

@PrepareForTest(DeviceInfo.class)
@Test
public void testTotalRAM() {
//Test with only total RAM information available.
int yearClass = getYearClass(DeviceInfo.DEVICEINFO_UNKNOWN,
DeviceInfo.DEVICEINFO_UNKNOWN, 6144L * 1024 * 1024);
assertEquals(YearClass.CLASS_2016, yearClass);
}

private int getYearClass(int numCores, int maxFreqKHz, long memoryBytes) {
mockStatic(DeviceInfo.class);
when(DeviceInfo.getNumberOfCPUCores()).thenReturn(numCores);
Expand Down

0 comments on commit 0355835

Please sign in to comment.