I think that it would be hard to argue that you can eat a cake 'unintentionally', unless sleepwalking. I feel that, in this circumstance, the しまう expression is used to acknowledge the fact that they know that what they did was wrong or unexpected and to show contrition or at least the appearance of contrition.
'I ate a slice of cake (even though I'm on a diet).'
'I had a bite of your cake (while you were turned around, couldn't control myself).'
'I ate the cake (that you're looking for in the fridge).'
All of these usages are equally valid.
As we cannot know from the context just how much cake was consumed it wouldn't be correct to assume that it meant the 'whole cake'. Also, ケーキ can refer to a large cake with many servings, a single-serving of cake, or even just a bite. It would be more likely that one would say 全部食べてしまいました if they ate the whole thing.
The use of ～てしまう/～ちゃう is extremely context-reliant and can be used in a myriad of ways. Here is just one resource to explain various usages.