Skip to content

Commit a7cedd3

Browse files
author
Andrew Beck
committed
Added Feature of being able to move the location of the fixed row,column and corner view.
This is also an enabler for Right to Left Support Added Instrumented Tests for moving Corner View location. Added two part class construction to enable setting of various properties before initilization to improve programmatic creation to be able to set the same properties as can be done from xml attributes.
1 parent 38bc1d0 commit a7cedd3

22 files changed

+1025
-25
lines changed

tableview/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ dependencies {
4747
implementation "androidx.annotation:annotation:$androidx_annotation_version"
4848
implementation "androidx.recyclerview:recyclerview:$androidx_recyclerview_version"
4949
testImplementation "junit:junit:4.13"
50+
androidTestImplementation "androidx.appcompat:appcompat:1.0.0"
5051
androidTestImplementation 'androidx.test:rules:1.2.0'
5152
androidTestImplementation 'androidx.test:runner:1.2.0'
5253
androidTestImplementation 'androidx.test.ext:junit:1.1.1'

tableview/src/androidTest/java/com/evrencoskun/tableview/test/CornerLayoutTest.java

Lines changed: 410 additions & 0 deletions
Large diffs are not rendered by default.

tableview/src/androidTest/java/com/evrencoskun/tableview/test/CornerViewTest.java

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import android.app.Activity;
2828
import android.view.View;
2929
import android.widget.LinearLayout;
30+
import android.widget.RelativeLayout;
3031
import android.widget.TextView;
3132

3233
import androidx.test.platform.app.InstrumentationRegistry;
@@ -69,6 +70,9 @@ public void testEmptyTable() throws Throwable {
6970
new TableView(InstrumentationRegistry.getInstrumentation().getTargetContext());
7071
Assert.assertNotNull(tableView);
7172

73+
RelativeLayout rl = new RelativeLayout(InstrumentationRegistry.getInstrumentation().getTargetContext());
74+
rl.addView(tableView);
75+
7276
SimpleTestAdapter simpleTestAdapter = new SimpleTestAdapter();
7377
Assert.assertNotNull(simpleTestAdapter);
7478

@@ -79,7 +83,7 @@ public void testEmptyTable() throws Throwable {
7983
simpleTestAdapter.setAllItems(simpleData.getColumnHeaders(), simpleData.getRowHeaders(),
8084
simpleData.getCells());
8185

82-
mActivityTestRule.runOnUiThread(() -> activity.setContentView(tableView));
86+
mActivityTestRule.runOnUiThread(() -> activity.setContentView(rl));
8387

8488
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
8589

@@ -96,6 +100,9 @@ public void testEmptyTableResetNonEmptyTable() throws Throwable {
96100
new TableView(InstrumentationRegistry.getInstrumentation().getTargetContext());
97101
Assert.assertNotNull(tableView);
98102

103+
RelativeLayout rl = new RelativeLayout(InstrumentationRegistry.getInstrumentation().getTargetContext());
104+
rl.addView(tableView);
105+
99106
SimpleTestAdapter simpleTestAdapter = new SimpleTestAdapter();
100107
Assert.assertNotNull(simpleTestAdapter);
101108

@@ -115,7 +122,7 @@ public void testEmptyTableResetNonEmptyTable() throws Throwable {
115122
simpleTestAdapter.setAllItems(simpleDataReset.getColumnHeaders(), simpleDataReset.getRowHeaders(),
116123
simpleDataReset.getCells());
117124

118-
mActivityTestRule.runOnUiThread(() -> activity.setContentView(tableView));
125+
mActivityTestRule.runOnUiThread(() -> activity.setContentView(rl));
119126

120127
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
121128

@@ -139,6 +146,9 @@ public void testEmptyTableResetEmptyTable() throws Throwable {
139146
new TableView(InstrumentationRegistry.getInstrumentation().getTargetContext());
140147
Assert.assertNotNull(tableView);
141148

149+
RelativeLayout rl = new RelativeLayout(InstrumentationRegistry.getInstrumentation().getTargetContext());
150+
rl.addView(tableView);
151+
142152
SimpleTestAdapter simpleTestAdapter = new SimpleTestAdapter();
143153
Assert.assertNotNull(simpleTestAdapter);
144154

@@ -158,7 +168,7 @@ public void testEmptyTableResetEmptyTable() throws Throwable {
158168
simpleTestAdapter.setAllItems(simpleDataReset.getColumnHeaders(), simpleDataReset.getRowHeaders(),
159169
simpleDataReset.getCells());
160170

161-
mActivityTestRule.runOnUiThread(() -> activity.setContentView(tableView));
171+
mActivityTestRule.runOnUiThread(() -> activity.setContentView(rl));
162172

163173
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
164174

@@ -176,6 +186,9 @@ public void testNonEmptyTable() throws Throwable {
176186
new TableView(InstrumentationRegistry.getInstrumentation().getTargetContext());
177187
Assert.assertNotNull(tableView);
178188

189+
RelativeLayout rl = new RelativeLayout(InstrumentationRegistry.getInstrumentation().getTargetContext());
190+
rl.addView(tableView);
191+
179192
SimpleTestAdapter simpleTestAdapter = new SimpleTestAdapter();
180193
Assert.assertNotNull(simpleTestAdapter);
181194

@@ -186,7 +199,7 @@ public void testNonEmptyTable() throws Throwable {
186199
simpleTestAdapter.setAllItems(simpleData.getColumnHeaders(), simpleData.getRowHeaders(),
187200
simpleData.getCells());
188201

189-
mActivityTestRule.runOnUiThread(() -> activity.setContentView(tableView));
202+
mActivityTestRule.runOnUiThread(() -> activity.setContentView(rl));
190203

191204
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
192205

@@ -210,6 +223,9 @@ public void testNonEmptyTableResetNonEmpty() throws Throwable {
210223
new TableView(InstrumentationRegistry.getInstrumentation().getTargetContext());
211224
Assert.assertNotNull(tableView);
212225

226+
RelativeLayout rl = new RelativeLayout(InstrumentationRegistry.getInstrumentation().getTargetContext());
227+
rl.addView(tableView);
228+
213229
SimpleTestAdapter simpleTestAdapter = new SimpleTestAdapter();
214230
Assert.assertNotNull(simpleTestAdapter);
215231

@@ -232,7 +248,7 @@ public void testNonEmptyTableResetNonEmpty() throws Throwable {
232248
simpleTestAdapter.setAllItems(simpleDataReset.getColumnHeaders(), simpleDataReset.getRowHeaders(),
233249
simpleDataReset.getCells());
234250

235-
mActivityTestRule.runOnUiThread(() -> activity.setContentView(tableView));
251+
mActivityTestRule.runOnUiThread(() -> activity.setContentView(rl));
236252

237253
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
238254

@@ -256,6 +272,9 @@ public void testNonEmptyTableResetEmpty() throws Throwable {
256272
new TableView(InstrumentationRegistry.getInstrumentation().getTargetContext());
257273
Assert.assertNotNull(tableView);
258274

275+
RelativeLayout rl = new RelativeLayout(InstrumentationRegistry.getInstrumentation().getTargetContext());
276+
rl.addView(tableView);
277+
259278
SimpleTestAdapter simpleTestAdapter = new SimpleTestAdapter();
260279
Assert.assertNotNull(simpleTestAdapter);
261280

@@ -276,7 +295,7 @@ public void testNonEmptyTableResetEmpty() throws Throwable {
276295
simpleTestAdapter.setAllItems(simpleDataReset.getColumnHeaders(), simpleDataReset.getRowHeaders(),
277296
simpleDataReset.getCells());
278297

279-
mActivityTestRule.runOnUiThread(() -> activity.setContentView(tableView));
298+
mActivityTestRule.runOnUiThread(() -> activity.setContentView(rl));
280299

281300
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
282301

@@ -296,6 +315,9 @@ public void testColumnHeadersOnlyTable() throws Throwable {
296315
new TableView(InstrumentationRegistry.getInstrumentation().getTargetContext());
297316
Assert.assertNotNull(tableView);
298317

318+
RelativeLayout rl = new RelativeLayout(InstrumentationRegistry.getInstrumentation().getTargetContext());
319+
rl.addView(tableView);
320+
299321
SimpleTestAdapter simpleTestAdapter = new SimpleTestAdapter();
300322
Assert.assertNotNull(simpleTestAdapter);
301323

@@ -307,7 +329,7 @@ public void testColumnHeadersOnlyTable() throws Throwable {
307329
simpleTestAdapter.setAllItems(simpleData.getColumnHeaders(), simpleData.getRowHeaders(),
308330
simpleData.getCells());
309331

310-
mActivityTestRule.runOnUiThread(() -> activity.setContentView(tableView));
332+
mActivityTestRule.runOnUiThread(() -> activity.setContentView(rl));
311333

312334
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
313335

@@ -325,6 +347,9 @@ public void testColumnHeadersOnlyTableResetNonEmptyTable() throws Throwable {
325347
new TableView(InstrumentationRegistry.getInstrumentation().getTargetContext());
326348
Assert.assertNotNull(tableView);
327349

350+
RelativeLayout rl = new RelativeLayout(InstrumentationRegistry.getInstrumentation().getTargetContext());
351+
rl.addView(tableView);
352+
328353
SimpleTestAdapter simpleTestAdapter = new SimpleTestAdapter();
329354
Assert.assertNotNull(simpleTestAdapter);
330355

@@ -346,7 +371,7 @@ public void testColumnHeadersOnlyTableResetNonEmptyTable() throws Throwable {
346371
simpleTestAdapter.setAllItems(simpleDataReset.getColumnHeaders(), simpleDataReset.getRowHeaders(),
347372
simpleDataReset.getCells());
348373

349-
mActivityTestRule.runOnUiThread(() -> activity.setContentView(tableView));
374+
mActivityTestRule.runOnUiThread(() -> activity.setContentView(rl));
350375

351376
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
352377

@@ -370,6 +395,9 @@ public void testColumnHeadersOnlyTableResetEmptyTable() throws Throwable {
370395
new TableView(InstrumentationRegistry.getInstrumentation().getTargetContext());
371396
Assert.assertNotNull(tableView);
372397

398+
RelativeLayout rl = new RelativeLayout(InstrumentationRegistry.getInstrumentation().getTargetContext());
399+
rl.addView(tableView);
400+
373401
SimpleTestAdapter simpleTestAdapter = new SimpleTestAdapter();
374402
Assert.assertNotNull(simpleTestAdapter);
375403

@@ -391,7 +419,7 @@ public void testColumnHeadersOnlyTableResetEmptyTable() throws Throwable {
391419
simpleTestAdapter.setAllItems(simpleDataReset.getColumnHeaders(), simpleDataReset.getRowHeaders(),
392420
simpleDataReset.getCells());
393421

394-
mActivityTestRule.runOnUiThread(() -> activity.setContentView(tableView));
422+
mActivityTestRule.runOnUiThread(() -> activity.setContentView(rl));
395423

396424
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
397425

@@ -409,6 +437,9 @@ public void testColumnHeadersOnlyTableShowCorner() throws Throwable {
409437
new TableView(InstrumentationRegistry.getInstrumentation().getTargetContext());
410438
Assert.assertNotNull(tableView);
411439

440+
RelativeLayout rl = new RelativeLayout(InstrumentationRegistry.getInstrumentation().getTargetContext());
441+
rl.addView(tableView);
442+
412443
// Set the option to show corner view when there is not row data
413444
tableView.setShowCornerView(true);
414445

@@ -423,7 +454,7 @@ public void testColumnHeadersOnlyTableShowCorner() throws Throwable {
423454
simpleTestAdapter.setAllItems(simpleData.getColumnHeaders(), simpleData.getRowHeaders(),
424455
simpleData.getCells());
425456

426-
mActivityTestRule.runOnUiThread(() -> activity.setContentView(tableView));
457+
mActivityTestRule.runOnUiThread(() -> activity.setContentView(rl));
427458

428459
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
429460

@@ -447,6 +478,9 @@ public void testColumnHeadersOnlyTableShowCornerResetEmptyTable() throws Throwab
447478
new TableView(InstrumentationRegistry.getInstrumentation().getTargetContext());
448479
Assert.assertNotNull(tableView);
449480

481+
RelativeLayout rl = new RelativeLayout(InstrumentationRegistry.getInstrumentation().getTargetContext());
482+
rl.addView(tableView);
483+
450484
// Set the option to show corner view when there is not row data
451485
tableView.setShowCornerView(true);
452486

@@ -471,7 +505,7 @@ public void testColumnHeadersOnlyTableShowCornerResetEmptyTable() throws Throwab
471505
simpleTestAdapter.setAllItems(simpleDataReset.getColumnHeaders(), simpleDataReset.getRowHeaders(),
472506
simpleDataReset.getCells());
473507

474-
mActivityTestRule.runOnUiThread(() -> activity.setContentView(tableView));
508+
mActivityTestRule.runOnUiThread(() -> activity.setContentView(rl));
475509

476510
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
477511

@@ -491,6 +525,9 @@ public void testColumnHeadersOnlyTableShowCornerResetNonEmptyTable() throws Thro
491525
new TableView(InstrumentationRegistry.getInstrumentation().getTargetContext());
492526
Assert.assertNotNull(tableView);
493527

528+
RelativeLayout rl = new RelativeLayout(InstrumentationRegistry.getInstrumentation().getTargetContext());
529+
rl.addView(tableView);
530+
494531
// Set the option to show corner view when there is not row data
495532
tableView.setShowCornerView(true);
496533

@@ -515,7 +552,7 @@ public void testColumnHeadersOnlyTableShowCornerResetNonEmptyTable() throws Thro
515552
simpleTestAdapter.setAllItems(simpleDataReset.getColumnHeaders(), simpleDataReset.getRowHeaders(),
516553
simpleDataReset.getCells());
517554

518-
mActivityTestRule.runOnUiThread(() -> activity.setContentView(tableView));
555+
mActivityTestRule.runOnUiThread(() -> activity.setContentView(rl));
519556

520557
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
521558

tableview/src/androidTest/java/com/evrencoskun/tableview/test/SimpleActivityTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import android.app.Activity;
2828
import android.widget.LinearLayout;
29+
import android.widget.RelativeLayout;
2930
import android.widget.TextView;
3031

3132
import androidx.test.platform.app.InstrumentationRegistry;
@@ -99,6 +100,9 @@ public void testSmallTable() throws Throwable {
99100
new TableView(InstrumentationRegistry.getInstrumentation().getTargetContext());
100101
Assert.assertNotNull(tableView);
101102

103+
RelativeLayout rl = new RelativeLayout(InstrumentationRegistry.getInstrumentation().getTargetContext());
104+
rl.addView(tableView);
105+
102106
SimpleTestAdapter simpleTestAdapter = new SimpleTestAdapter();
103107
Assert.assertNotNull(simpleTestAdapter);
104108

@@ -109,7 +113,8 @@ public void testSmallTable() throws Throwable {
109113
simpleTestAdapter.setAllItems(simpleData.getColumnHeaders(), simpleData.getRowHeaders(),
110114
simpleData.getCells());
111115

112-
mActivityTestRule.runOnUiThread(() -> activity.setContentView(tableView));
116+
117+
mActivityTestRule.runOnUiThread(() -> activity.setContentView(rl));
113118

114119
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
115120

0 commit comments

Comments
 (0)