This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyComposeTest { | |
@get:Rule | |
val composeTestRule = createComposeRule() | |
val composeTestRuleWithActivity = createAndroidComposeRule<YourActivity>() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyLayoutTest { | |
@get:Rule | |
val composeTestRule = createAndroidComposeRule<ComponentActivity>() | |
@Test | |
fun testMyLayout() { | |
// Start the app | |
composeTestRule.setContent { | |
MyLayout() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<EditText android:id="@+id/name_field" | |
android:layout_width="wrap_content" | |
android:hint="Please enter your name" android:layout_height="wrap_content" /> | |
<Button android:id="@+id/greet_button" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" android:text="Click me to greet!" /> | |
<Text android:id="@+id/greet_field" android:layout_width="wrap_content" | |
android:visibility="gone" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun enrichInvoice(invoice: Invoice, author: String, timeStamp: LocalDateTime): Invoice { | |
return invoice.copy(printingAuthor = author, printTimeStamp = timeStamp) | |
} | |
fun main() { | |
var invoice = Utils.getRandomInvoice(this, resources.configuration.locale) | |
invoice = controller.enrichInvoice(invoice,"Nicola", LocalDateTime.now()) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun addAuthor(invoice: Invoice, author: String): Invoice { | |
return invoice.copy(printingAuthor = author) | |
} | |
fun addPrintTimeStamp(invoice: Invoice, timeStamp: LocalDateTime): Invoice { | |
return invoice.copy(printTimeStamp = timeStamp) | |
} | |
fun main() { | |
var invoice = Utils.getRandomInvoice(this, resources.configuration.locale) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Both functions print something | |
private fun printInvoiceHeader(header: InvoiceHeader) { | |
binding.tvInvoicePreview.text = header.toString() | |
} | |
private fun printCustomerDetails(customer: Customer) { | |
var customerDetails = "" | |
customerDetails += "CUSTOMER\n" | |
customerDetails += "First Name: ${customer.firstName}\nLast Name: ${customer.lastName}\n" | |
binding.tvInvoicePreview.append("$customerDetails\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun printInvoiceHeader(header: InvoiceHeader) { | |
binding.tvInvoicePreview.text = header.toString() | |
} | |
data class InvoiceHeader(private val number: Int, private val date: LocalDate) { | |
override fun toString(): String { | |
return "INVOICE N° ${number}, ${formatter.format(date)}\n\n" | |
} | |
companion object { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun printInvoiceHeader(invoiceNumber: Int, invoiceDate: LocalDate, format: DateTimeFormatter) { | |
val invoiceHeader = | |
"INVOICE N° ${invoiceNumber}, ${invoiceDate.format(format)}\n\n" | |
binding.tvInvoicePreview.text = invoiceHeader | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun printInvoiceSheet(invoice: Invoice) { | |
printInvoiceHeader(invoiceNumber = invoice.number, invoiceDate = invoice.date) | |
printInvoiceItemsSection(invoice.items, 22.0) | |
} | |
private fun printInvoiceHeader(invoiceNumber: Int, invoiceDate: LocalDate) { | |
val invoiceHeader = "INVOICE N° ${invoiceNumber}, ${invoiceDate}\n\n" | |
binding.tvInvoicePreview.text = invoiceHeader | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun printInvoiceSheet(invoice: Invoice) { | |
printDetails(invoice) | |
printInvoiceItemsSection(invoice.items, 22.0) | |
} | |
private fun printDetails(invoice: Invoice) { | |
val invoiceHeader = "INVOICE N° ${invoice.number}, ${invoice.date}\n\n" | |
binding.tvInvoicePreview.text = invoiceHeader | |
} |