There are few things as nice as watching a movie, listening to a good podcast or getting some work done on the train, and fortunately most long distance trains in Europe today offer free wifi onboard. Eurostar, Renfe, SNCF and Deutsche Bahn let you get access to wifi on the majority of their trains. If it's super important to you, the best way to really know if wifi is available is to google the name of the train (that can be found on your ticket) and you'll find out.
For EU residents
Should the wifi connection let you down, as an EU resident, you still have the luxury to take advantage of free roaming in all EU countries, just remember to turn on roaming in your phone's settings. If you are an EU resident traveling through a non-EU country such as Switzerland, the UK, or Norway, it could be a good idea to bring a 4G dongle in your bag, and switch off roaming to avoid hefty bills.