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

Commit 4cbeaf67 authored by jeffreyhuang's avatar jeffreyhuang
Browse files

Introduce BuildNumberDialogController

 - Create a controller to display data and for the
  build number field in FirmwareVersionDialogFragment

Bug: 36458278
Test: make RunSettingsRoboTests -j40
Change-Id: Ie283981d6e7ed519df1a77fd21158feb37f0efd8
parent 890d3c76
Loading
Loading
Loading
Loading
+43 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.settings.deviceinfo.firmwareversion;

import android.os.Build;
import android.support.annotation.VisibleForTesting;
import android.text.BidiFormatter;

import com.android.settings.R;

public class BuildNumberDialogController {

    @VisibleForTesting
    static final int BUILD_NUMBER_VALUE_ID = R.id.build_number_value;

    private final FirmwareVersionDialogFragment mDialog;

    public BuildNumberDialogController(FirmwareVersionDialogFragment dialog) {
        mDialog = dialog;
    }

    /**
     * Updates the build number to the dialog.
     */
    public void initialize() {
        mDialog.setText(BUILD_NUMBER_VALUE_ID,
                BidiFormatter.getInstance().unicodeWrap(Build.DISPLAY));
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -88,5 +88,6 @@ public class FirmwareVersionDialogFragment extends InstrumentedDialogFragment {
        new SecurityPatchLevelDialogController(this).initialize();
        new BasebandVersionDialogController(this).initialize();
        new KernelVersionDialogController(this).initialize();
        new BuildNumberDialogController(this).initialize();
    }
}
+59 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.settings.deviceinfo.firmwareversion;

import static com.android.settings.deviceinfo.firmwareversion.BuildNumberDialogController
        .BUILD_NUMBER_VALUE_ID;

import static org.mockito.Mockito.verify;

import android.os.Build;
import android.text.BidiFormatter;

import com.android.settings.TestConfig;
import com.android.settings.testutils.SettingsRobolectricTestRunner;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;

@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BuildNumberDialogControllerTest {

    @Mock
    private FirmwareVersionDialogFragment mDialog;

    private BuildNumberDialogController mController;

    @Before
    public void setup() {
        MockitoAnnotations.initMocks(this);
        mController = new BuildNumberDialogController(mDialog);
    }

    @Test
    public void initialize_shouldUpdateBuildNumberToDialog() {
        mController.initialize();

        verify(mDialog).setText(BUILD_NUMBER_VALUE_ID,
                BidiFormatter.getInstance().unicodeWrap(Build.DISPLAY));
    }
}