Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f4b229fd authored by AI test gen's avatar AI test gen
Browse files

Add test for ProtoLog calls before initialization.

Verifies that calling ProtoLog logging methods before `ProtoLog.init()`
does not throw an exception, confirming the intended behavior of
preventing crashes in this scenario.



Please help fill out the survey for feedback: https://docs.google.com/forms/d/e/1FAIpQLSeKFKpHImCAqZIa_OR801cw72HQUreM2oGM25C3mKKT2tBFnw/viewform?usp=pp_url&entry.1586624956=ag/35401635

Original Change: ag/35157468
Test: ATP tests passed http://go/forrest-run/L95900030017377343
Bug: 431235865
Flag: TEST_ONLY

Change-Id: Id21a303caf98cc8d2181d4b5fc3a8e712a88d315
parent d0d82558
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -55,6 +55,21 @@ public class ProtoLogTest {
        ProtoLog.setControllerInstanceForTest(mController);
    }

    @Test
    public void log_whenUninitialized_doesNotThrow() {
        // This test verifies that calling any ProtoLog logging method before the
        // system is initialized does not cause a crash. The change this test covers
        // replaced an IllegalStateException with a Log.wtf() call.

        // The test passes if no exception is thrown for any of the log levels.
        ProtoLog.d(TEST_GROUP_1, "Debug log call before init");
        ProtoLog.v(TEST_GROUP_1, "Verbose log call before init");
        ProtoLog.i(TEST_GROUP_1, "Info log call before init");
        ProtoLog.w(TEST_GROUP_1, "Warning log call before init");
        ProtoLog.e(TEST_GROUP_1, "Error log call before init");
        ProtoLog.wtf(TEST_GROUP_1, "WTF log call before init");
    }

    @Test
    public void canRunProtoLogInitMultipleTimes() {
        ProtoLog.init(TEST_GROUP_1);